コード例 #1
0
        public void ByElement_CreatesComparerBasedOnAllElementsEquality()
        {
            var comparer = EqualityComparer.ByElements <IEnumerable <string> >();

            comparer.Should()
            .HandleBasicEqualitiesAndInequalites()
            .And.ValidateEqualityOf(
                new[] { "a", "b", "c" },
                new[] { "a", "b", "c" },
                "sequences with equals elements should equals")
            .And.ValidateEqualityOf(
                new[] { "a", "b", null },
                new[] { "a", "b", null },
                "sequences with equals elements should equals even if some elements are nulls")
            .And.ValidateEqualityOf(
                new List <string> {
                "a", "b", "c"
            },
                new HashSet <string> {
                "a", "b", "c"
            },
                "sequences with equals elements should equals even if their types are different")
            .And.InvalidateEqualityOf(
                new[] { "a", "b", "c" },
                new[] { "d", "e", "f" },
                "sequences with different elements shouldn't equals");
        }