Dictionary Assertions
An assertion tool to verify dictionaries.
-
GdUnitDictionaryAssert
Function Description is_null Verifies that the current value is null. is_not_null Verifies that the current value is not null. is_equal Verifies that the current dictionary is equal to the given one, ignoring order. is_not_equal Verifies that the current dictionary is not equal to the given one, ignoring order. is_same Verifies that the current dictionary is the same. is_not_same Verifies that the current dictionary is NOT the same. is_empty Verifies that the current dictionary is empty, it has a size of 0. is_not_empty Verifies that the current dictionary is not empty, it has a size of minimum 1. has_size Verifies that the current dictionary has a size of given value. contains_keys Verifies that the current dictionary contains the given keys. contains_key_value Verifies that the current dictionary contains the given key and value. not_contains_keys Verifies that the current dictionary not contains the given keys. contains_same_keys Verifies that the current dictionary contains the given keys. contains_same_key_value Verifies that the current dictionary contains the given key and value. not_contains_same_keys Verifies that the current dictionary not contains the given keys. -
IDictionaryAssert
Function Description IsNull Verifies that the current value is null. IsNotNull Verifies that the current value is not null. IsEqual Verifies that the current dictionary is equal to the given one, ignoring order. IsNotEqual Verifies that the current dictionary is not equal to the given one, ignoring order. IsSame Verifies that the current dictionary is the same. IsNotSame Verifies that the current dictionary is NOT the same. IsEmpty Verifies that the current dictionary is empty, it has a size of 0. IsNotEmpty Verifies that the current dictionary is not empty, it has a size of minimum 1. HasSize Verifies that the current dictionary has a size of given value. ContainsKeys Verifies that the current dictionary contains the given keys. ContainsKeyValue Verifies that the current dictionary contains the given key and value. NotContainsKeys Verifies that the current dictionary not contains the given keys. ContainsSameKeys Verifies that the current dictionary contains the given keys. ContainsSameKeyValue Verifies that the current dictionary contains the given key and value. NotContainsSameKeys Verifies that the current dictionary not contains the given keys.
Dictionary Assert Examples
is_null
Verifies that the current value is null.
-
func assert_dict(<current>).is_null() -> GdUnitDictionaryAssert
# this assertion succeeds assert_dict(null).is_null() # should fail because the dictionary is not null assert_dict({}).is_null()
-
public static IDictionaryAssert AssertThat(current).IsNull(); public static IDictionaryAssert AssertThat<K, V>(current).IsNull();
// this assertion succeeds AssertThat(null).IsNull(); // should fail because it not null AssertThat(new Hashtable()).IsNull();
is_not_null
Verifies that the current value is not null.
-
func assert_dict(<current>).is_not_null() -> GdUnitDictionaryAssert
# this assertion succeeds assert_dict({}).is_not_null() # should fail because the dictionary is null assert_dict(null).is_not_null()
-
public static IDictionaryAssert AssertThat(current).IsNotNull(); public static IDictionaryAssert AssertThat<K, V>(current).IsNotNull();
// this assertion succeeds AssertThat(new Hashtable()).IsNotNull(); // should fail because the current value is null AssertThat(null).IsNotNull();
is_equal
Verifies that the current dictionary is equal to the given one, ignoring order.
The values are compared by deep parameter comparision, for object reference compare you have to use is_same.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).is_equal(<expected>) -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict({}).is_equal({}) assert_dict({1:1}).is_equal({1:1}) assert_dict({1:1, "key_a": "value_a"}).is_equal({1:1, "key_a": "value_a" }) # different order is also equals assert_dict({"key_a": "value_a", 1:1}).is_equal({1:1, "key_a": "value_a" }) # should fail assert_dict({}).is_equal({1:1}) assert_dict({1:1}).is_equal({1:2}) assert_dict({1:1, "key_a": "value_a"}).is_equal({1:1, "key_b": "value_b"})
-
public static IDictionaryAssert AssertThat(current).IsEqual(); public static IDictionaryAssert AssertThat<K, V>(current).IsEqual();
// this assertion succeeds AssertThat(new Hashtable()).IsEqual(new Hashtable()); // should fail because is not equal AssertThat(new Hashtable()).IsEqual(new Hashtable() { { 1, 1 } });
is_not_equal
Verifies that the current dictionary is not equal to the given one, ignoring order.
The values are compared by deep parameter comparision, for object reference compare you have to use is_not_same.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).is_not_equal(<expected>) -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict(null).is_not_equal({}) assert_dict({}).is_not_equal(null) assert_dict({}).is_not_equal({1:1}) assert_dict({1:1}).is_not_equal({}) assert_dict({1:1}).is_not_equal({1:2}) assert_dict({2:1}).is_not_equal({1:1}) assert_dict({1:1}).is_not_equal({1:1, "key_a": "value_a"}) assert_dict({1:1, "key_a": "value_a"}).is_not_equal({1:1}) assert_dict({1:1, "key_a": "value_a"}).is_not_equal({1:1,"key_b": "value_b"}) # should fail assert_dict({}).is_not_equal({}) assert_dict({1:1}).is_not_equal({1:1}) assert_dict({1:1, "key_a": "value_a"}).is_not_equal({1:1, "key_a": "value_a"}) assert_dict({"key_a": "value_a", 1:1}).is_not_equal({1:1, "key_a": "value_a"})
-
public static IDictionaryAssert AssertThat(current).IsNotEqual(); public static IDictionaryAssert AssertThat<K, V>(current).IsNotEqual();
// this assertion succeeds AssertThat(new Hashtable()).IsNotEqual(new Hashtable() { { 1, 1 } }); // should fail because it is equal AssertThat(new Hashtable()).IsNotEqual(new Hashtable());
is_same
Verifies that the current dictionary is the same.
The dictionary are compared by object reference, for deep parameter comparision use is_equal.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).is_same(<expected>) -> GdUnitDictionaryAssert:
var a := { "key_a": "value_a", "key_b": "value_b"} var b := { "key_a": "value_a", "key_b": "value_b"} # this assertion succeeds assert_dict(a).is_same(a) # should fail assert_dict(a).is_same(b)
-
public static IDictionaryAssert AssertThat(current).IsSame(); public static IDictionaryAssert AssertThat<K, V>(current).IsSame();
Hashtable a = new Hashtable(); Hashtable b = new Hashtable(); // this assertion succeeds AssertThat(a).IsSame(a); // should fail because is not equal AssertThat(a).IsSame(b);
is_not_same
Verifies that the current dictionary is NOT the same.
The dictionary are compared by object reference, for deep parameter comparision use is_not_equal.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).is_not_same(<expected>) -> GdUnitDictionaryAssert:
var a := { "key_a": "value_a", "key_b": "value_b"} var b := { "key_a": "value_a", "key_b": "value_b"} # this assertion succeeds assert_dict(a).is_not_same(b) # should fail assert_dict(a).is_not_same(a)
-
public static IDictionaryAssert AssertThat(current).IsNotSame(); public static IDictionaryAssert AssertThat<K, V>(current).IsNotSame();
Hashtable a = new Hashtable(); Hashtable b = new Hashtable(); // this assertion succeeds AssertThat(a).IsNotSame(b); // should fail because is not equal AssertThat(a).IsNotSame(a);
is_empty
Verifies that the current dictionary is empty, it has a size of 0.
-
func assert_dict(<current>).is_empty() -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict({}).is_empty() # should fail assert_dict(null).is_empty() assert_dict({1:1}).is_empty()
-
public static IDictionaryAssert AssertThat(current).IsEmpty(); public static IDictionaryAssert AssertThat<K, V>(current).IsEmpty();
// this assertion succeeds AssertThat(new Hashtable()).IsEmpty(); // should fail because it is NOT empty AssertThat(new Hashtable() { { 1, 1 } }).IsEmpty();
is_not_empty
Verifies that the current dictionary is not empty, it has a size of minimum 1.
-
func assert_dict(<current>).is_not_empty() -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict({1:1}).is_not_empty() assert_dict({1:1, "key_a": "value_a"}).is_not_empty() # should fail assert_dict(null).is_not_empty() assert_dict({}).is_not_empty()
-
public static IDictionaryAssert AssertThat(current).IsNotEmpty(); public static IDictionaryAssert AssertThat<K, V>(current).IsNotEmpty();
// this assertion succeeds AssertThat(new Hashtable() { { 1, 1 } }).IsNotEmpty(); // should fail because it is empty AssertThat(new Hashtable()).IsNotEmpty();
has_size
Verifies that the current dictionary has a size of given value.
-
func assert_dict(<current>).has_size(<expected>) -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict({}).has_size(0) assert_dict({1:1, 2:1, 3:1}).has_size(3) # should fail assert_dict(null).has_size(0) assert_dict({}).has_size(1) assert_dict({1:1, 2:1, 3:1}).has_size(4)
-
public static IDictionaryAssert AssertThat(current).HasSize(<count>); public static IDictionaryAssert AssertThat<K, V>(current).HasSize(<count>);
// this assertion succeeds AssertThat(new Hashtable() { { 1, 1 } }).HasSize(1); // should fail because it is empty AssertThat(new Hashtable()).HasSize(1);
contains_keys
Verifies that the current dictionary contains the given key(s).
The values are compared by deep parameter comparision, for object reference compare you have to use contains_same_keys.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).contains_keys(<expected>: Array) -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict({1:1, 2:2, 3:3}).contains_keys([2]) assert_dict({1:1, 2:2, "key_a": "value_a"}).contains_keys([2, "key_a"]) # should fail assert_dict({1:1, 3:3}).contains_keys([2]) # key 2 is missing assert_dict({1:1, 3:3}).contains_keys([1, 4]) # key 4 is missing
-
public static IDictionaryAssert AssertThat(current).ContainsKeys(<keys>); public static IDictionaryAssert AssertThat<K, V>(current).ContainsKeys(<keys>);
// this assertion succeeds AssertThat(new Hashtable() { { "a", 1 }, { "b", 2} }).ContainsKeys("a", "b"); // should fail because it not contains key "c" AssertThat(new Hashtable() { { "a", 1 }, { "b", 2} }).ContainsKeys("a", "c");
contains_key_value
Verifies that the current dictionary contains the given key and value.
The values are compared by deep parameter comparision, for object reference compare you have to use contains_same_key_value.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func contains_key_value(<key>, <value>) -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict({1:1}).contains_key_value(1, 1) assert_dict({1:1, 2:2, 3:3}).contains_key_value(3, 3).contains_key_value(1, 1) # should fail assert_dict({1:1}.contains_key_value(1, 2) # contains key '1' but with value '2'
-
public static IDictionaryAssert AssertThat(current).ContainsKeyValue(<keys>); public static IDictionaryAssert AssertThat<K, V>(current).ContainsKeyValue(<keys>);
// this assertion succeeds AssertThat(new Hashtable() { { "a", 1 }, { "b", 2} }).ContainsKeyValue("a", "1"); // should fail because it NOT contains key and value "a:2" AssertThat(new Hashtable() { { "a", 1 }, { "b", 2} }).ContainsKeyValue("a", "2");
not_contains_keys
Verifies that the current dictionary not contains the given key(s).
The values are compared by deep parameter comparision, for object reference compare you have to use not_contains_same_keys.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).not_contains_keys(<expected>: Array) -> GdUnitDictionaryAssert:
# this assertion succeeds assert_dict({}).not_contains_keys([2]) assert_dict({1:1, 3:3}).not_contains_keys([2]) assert_dict({1:1, 3:3}).not_contains_keys([2, 4]) # should fail assert_dict({1:1, 2:2, 3:3}).not_contains_keys([2, 4]) # but contains 2 assert_dict({1:1, 2:2, 3:3}.not_contains_keys([1, 2, 3, 4]) # but contains 1, 2, 3
-
public static IDictionaryAssert AssertThat(current).NotContainsKeys(<keys>); public static IDictionaryAssert AssertThat<K, V>(current).NotContainsKeys(<keys>);
// this assertion succeeds AssertThat(new Hashtable() { { "a", 1 }, { "b", 2} }).ContainsKeys("c", "d"); // should fail because it contains key "b" AssertThat(new Hashtable() { { "a", 1 }, { "b", 2} }).NotContainsKeys("b", "c");
contains_same_keys
Verifies that the current dictionary contains the given key(s).
The dictionary are compared by object reference, for deep parameter comparision use contains_keys.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).contains_same_keys(<expected>: Array) -> GdUnitDictionaryAssert:
var key_a := Node.new() var key_b := Node.new() var key_c := Node.new() var dict_a := { key_a:"foo", key_b:"bar" } # this assertion succeeds assert_dict(dict_a).contains_same_keys([key_a]) # should fail assert_dict(a).contains_same_keys([key_c]) # key_c is missing
-
public static IDictionaryAssert AssertThat(current).ContainsSameKeys(<keys>); public static IDictionaryAssert AssertThat<K, V>(current).ContainsSameKeys(<keys>);
String key_a = "a"; String key_b = "b"; String key_c = "c"; Hashtable dict_a = new Hashtable() { { key_a, "foo" }, { key_b, "bar"} }; // this assertion succeeds AssertThat(dict_a).ContainsSameKeys(key_a); // should fail because it not contains key "c" AssertThat(dict_a).ContainsSameKeys(key_c);
contains_same_key_value
Verifies that the current dictionary contains the given key and value.
The values are compared by deep parameter comparision, for object reference compare you have to use contains_key_value.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func contains_same_key_value(<key>, <value>) -> GdUnitDictionaryAssert:
var key_a := Node.new() var key_b := Node.new() var value_a := Node.new() var value_b := Node.new() var dict_a := { key_a:value_a, key_b:value_b } # this assertion succeeds assert_dict(dict_a)\ .contains_same_key_value(key_a, value_a)\ .contains_same_key_value(key_b, value_b) # should fail because it NOT contains key with value key_a, value_b assert_dict(dict_a).contains_same_key_value(key_a, value_b)
-
public static IDictionaryAssert AssertThat(current).ContainsSameKeyValue(<keys>); public static IDictionaryAssert AssertThat<K, V>(current).ContainsSameKeyValue(<keys>);
String key_a = "a"; String key_b = "b"; String value_a = "foo"; String value_b = "bar"; Hashtable dict_a = new Hashtable() { { key_a, value_a }, { key_b, value_b} }; // this assertion succeeds AssertThat(dict_a).ContainsSameKeyValue(key_a, value_a); // should fail because it NOT contains key with value key_a, value_b AssertThat(dict_a).ContainsSameKeyValue(key_a, value_b);
not_contains_same_keys
Verifies that the current dictionary not contains the given key(s).
The values are compared by deep parameter comparision, for object reference compare you have to use not_contains_keys.
For more details about comparision works see How GdUnit Asserts compares Objects
-
func assert_dict(<current>).not_contains_same_keys(<expected>: Array) -> GdUnitDictionaryAssert:
var key_a := Node.new() var key_b := Node.new() var key_c := Node.new() var dict_a := { key_a:"foo", key_b:"bar" } # this assertion succeeds assert_dict(dict_a).not_contains_same_keys([key_c]) # should fail because it contains key_a and key_b assert_dict(dict_a).not_contains_same_keys(key_a) assert_dict(dict_a).not_contains_same_keys(key_b)
-
public static IDictionaryAssert AssertThat(current).NotContainsSameKeys(<keys>); public static IDictionaryAssert AssertThat<K, V>(current).NotContainsSameKeys(<keys>);
String key_a = "a"; String key_b = "b"; String key_c = "b"; Hashtable dict_a = new Hashtable() { { key_a, "foo" }, { key_b, "bar"} }; // this assertion succeeds AssertThat(dict_a).NotContainsSameKeys(key_c); // should fail because it contains key "a" and "b" AssertThat(dict_a).NotContainsSameKeys(key_a); AssertThat(dict_a).NotContainsSameKeys(key_b);