예제 #1
0
        public void CollectionsWithSameCountOfNulls_ShouldBeEqual()
        {
            var first  = new[] { "a", null, null };
            var second = new[] { null, "a", null };

            Assert.IsTrue(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #2
0
        public void ShouldUseGivenEqualityComparer()
        {
            var first  = new[] { 1 };
            var second = new[] { 22 };

            Assert.IsTrue(MultiSetEqualityComparer.Equals(first, second, new AlwaysEqualsEqualityComparer <int>()));
        }
예제 #3
0
        public void NullCollections_ShouldBeEqual()
        {
            var first  = (string[])null;
            var second = (string[])null;

            Assert.IsTrue(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #4
0
        public void CollectionsWithDifferentNullItemsCount_ShouldBeNotEqual()
        {
            var first  = new[] { "a", null };
            var second = new[] { null, "a", null };

            Assert.IsFalse(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #5
0
        public void MultisetCollectionsWithDifferentCountsOfItem_ShouldBeNotEqual()
        {
            var first  = new[] { "a", "b", "b" };
            var second = new[] { "a", "a", "b" };

            Assert.IsFalse(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #6
0
        public void ShouldHandleNullItems()
        {
            var first  = new[] { "a", null };
            var second = new[] { "a", null };

            Assert.IsTrue(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #7
0
        public void ShuffledCollectionsWithSameItems_ShouldBeEqual()
        {
            var first  = new[] { "a", "b" };
            var second = new[] { "b", "a" };

            Assert.IsTrue(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #8
0
        public void NotNullCollection_ShouldBeNotEqualToNullOne()
        {
            var first  = new string[] { };
            var second = (string[])null;

            Assert.IsFalse(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #9
0
        public void EmptyCollections_ShouldBeEqual()
        {
            var first  = new string[] { };
            var second = new string[] { };

            Assert.IsTrue(MultiSetEqualityComparer.Equals(first, second));
        }
예제 #10
0
        public bool Equals(CollectionByValue <T> other)
        {
            if (other is null)
            {
                return(false);
            }

            var inOrder = Options.InOrder || other.Options.InOrder;

            if (inOrder)
            {
                if (_collection is null)
                {
                    return(other._collection is null);
                }
                if (other._collection is null)
                {
                    return(false);
                }

                if (_collection.Count != other._collection.Count)
                {
                    return(false);
                }

                return(_collection.SequenceEqual(other._collection, Options.EqualityComparer));
            }
            else
            {
                return(MultiSetEqualityComparer.Equals(_collection, other._collection, Options.EqualityComparer));
            }
        }
예제 #11
0
        public bool Equals(DictionaryByValue <TKey, TValue> other)
        {
            if (other is null)
            {
                return(false);
            }

            return(MultiSetEqualityComparer.Equals(
                       _collection,
                       other._collection,
                       Options.KeysEqualityComparer,
                       Options.ValuesEqualityComparer));
        }
예제 #12
0
        public void NullDicts_ShouldBeEqual()
        {
            var first  = (IDict)null;
            var second = (IDict)null;

            Assert.IsTrue(MultiSetEqualityComparer.Equals(first, second, default, default));