public void When_comparing_dictionaries() { IDictionary <string, int> left = new Dictionary <string, int>(); IDictionary <string, int> right = new Dictionary <string, int>(); DictionaryExtensions.Equals(left, right).ShouldBeTrue(); left.Add("A", 1); DictionaryExtensions.Equals(left, right).ShouldBeFalse(); right.Add("A", 1); DictionaryExtensions.Equals(left, right).ShouldBeTrue(); left["A"] = 2; DictionaryExtensions.Equals(left, right).ShouldBeFalse(); right["A"] = 2; right["B"] = 3; DictionaryExtensions.Equals(left, right).ShouldBeFalse(); left["B"] = 3; DictionaryExtensions.Equals(left, right).ShouldBeTrue(); DictionaryExtensions.Equals(((IDictionary <string, int>)null), right).ShouldBeFalse(); left = right; DictionaryExtensions.Equals(left, null).ShouldBeFalse(); DictionaryExtensions.Equals(((IDictionary <string, int>)null), null).ShouldBeTrue(); }
public void When_comparing_dictionaries_with_comparer() { IDictionary <int, string> left = new Dictionary <int, string>(); IDictionary <int, string> right = new Dictionary <int, string>(); var comparer = StringComparer.OrdinalIgnoreCase; DictionaryExtensions.Equals(left, right, comparer).ShouldBeTrue(); left.Add(1, "A"); DictionaryExtensions.Equals(left, right, comparer).ShouldBeFalse(); right.Add(1, "A"); DictionaryExtensions.Equals(left, right, comparer).ShouldBeTrue(); left[2] = "A"; DictionaryExtensions.Equals(left, right, comparer).ShouldBeFalse(); right[2] = "A"; right[3] = "B"; DictionaryExtensions.Equals(left, right, comparer).ShouldBeFalse(); left[3] = "B"; DictionaryExtensions.Equals(left, right, comparer).ShouldBeTrue(); left[3] = "b"; DictionaryExtensions.Equals(left, right, comparer).ShouldBeTrue(); DictionaryExtensions.Equals(((IDictionary <int, string>)null), right, comparer).ShouldBeFalse(); left = right; DictionaryExtensions.Equals(left, null, comparer).ShouldBeFalse(); DictionaryExtensions.Equals(((IDictionary <int, string>)null), null, comparer).ShouldBeTrue(); }
public void When_comparing_easy_dictionaries() { IReadOnlyDictionary <string, Person> left = new EasyDictionary <string, Person>(p => p.Id); IReadOnlyDictionary <string, Person> right = new EasyDictionary <string, Person>(p => p.Id); DictionaryExtensions.Equals(left, right).ShouldBeTrue(); ((IEasyDictionary <string, Person>)left).Add(new Person("A", 1)); DictionaryExtensions.Equals(left, right).ShouldBeFalse(); ((IEasyDictionary <string, Person>)right).Add(new Person("A", 1)); DictionaryExtensions.Equals(left, right).ShouldBeTrue(); DictionaryExtensions.Equals(((IDictionary <int, string>)null), null).ShouldBeTrue(); }
public bool Equals(GameChannelKey other) { return(DictionaryExtensions.Equals(this.Properties, other.Properties)); }