Exemple #1
0
        /// <summary>
        /// Compares two lists for equivalence.
        /// Objects in both lists must be the same
        /// and in the same position.
        /// </summary>
        /// <param name="list1">The first list to compare.
        /// Can not be null.</param>
        /// <param name="list2">The second list to compare.
        /// Can be null.</param>
        /// <returns><c>true</c> if the collections
        /// are equal; <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">
        /// Raised if <c>list1</c> is <c>null</c>.</exception>
        public static bool IsEqualList(
            this IList list1,
            IList list2)
        {
            AssertArg.IsNotNull(list1, nameof(list1));

            return(CollectionComparer.AreEqualLists(list1, list2));
        }
Exemple #2
0
        public void AreEqualListsShouldReturnTrueIfEqual()
        {
            var dictionary1 = CreateDummyDictionary();
            var dictionary2 = CreateDummyDictionary();

            var list1 = new List <object>(dictionary1.Values);
            var list2 = new List <object>(dictionary2.Values);

            bool areEqual = CollectionComparer.AreEqualLists(list1, list2);

            Assert.IsTrue(areEqual);
        }
Exemple #3
0
        public void AreEqualListsShouldReturnFalseIfContainsMoreElements()
        {
            var dictionary1 = CreateDummyDictionary();
            var dictionary2 = CreateDummyDictionary();

            dictionary2.Add("Foo2", new object());

            var list1 = new List <object>(dictionary1.Values);
            var list2 = new List <object>(dictionary2.Values);

            bool areEqual = CollectionComparer.AreEqualLists(list1, list2);

            Assert.IsFalse(areEqual);
        }
Exemple #4
0
        public void AreEqualListsShouldReturnFalseIfValueDifferent()
        {
            var dictionary1 = CreateDummyDictionary();
            var dictionary2 = CreateDummyDictionary();
            var firstKey    = dictionary1.First().Key;

            dictionary1[firstKey] = new object();

            var list1 = new List <object>(dictionary1.Values);
            var list2 = new List <object>(dictionary2.Values);

            bool areEqual = CollectionComparer.AreEqualLists(list1, list2);

            Assert.IsFalse(areEqual);
        }