/// <summary>
        /// Creates a new instance of the <see href="AssertActualExpectedException"/> class.
        /// </summary>
        /// <param name="expected">The expected value</param>
        /// <param name="actual">The actual value</param>
        /// <param name="userMessage">The user message to be shown</param>
        /// <param name="skipPositionCheck">Set to true to skip the check for difference position</param>
        public AssertActualExpectedException(object expected,
                                             object actual,
                                             string userMessage,
                                             bool skipPositionCheck)
            : base(userMessage)
        {
            if (!skipPositionCheck)
            {
                IEnumerable enumerableActual   = actual as IEnumerable;
                IEnumerable enumerableExpected = expected as IEnumerable;

                if (enumerableActual != null && enumerableExpected != null)
                {
                    var comparer = new EnumerableEqualityComparer();
                    comparer.Equals(enumerableActual, enumerableExpected);

                    differencePosition = "Position: First difference is at position " + comparer.Position + Environment.NewLine;
                }
            }

            this.actual   = actual == null ? null : ConvertToString(actual);
            this.expected = expected == null ? null : ConvertToString(expected);

            if (actual != null &&
                expected != null &&
                actual.ToString() == expected.ToString() &&
                actual.GetType() != expected.GetType())
            {
                this.actual   += String.Format(" ({0})", actual.GetType().FullName);
                this.expected += String.Format(" ({0})", expected.GetType().FullName);
            }
        }
        /// <summary>
        /// Creates a new instance of the <see href="AssertActualExpectedException"/> class.
        /// </summary>
        /// <param name="expected">The expected value</param>
        /// <param name="actual">The actual value</param>
        /// <param name="userMessage">The user message to be shown</param>
        /// <param name="skipPositionCheck">Set to true to skip the check for difference position</param>
        public AssertActualExpectedException(object expected,
                                             object actual,
                                             string userMessage,
                                             bool skipPositionCheck)
            : base(userMessage)
        {
            if (!skipPositionCheck)
            {
                IEnumerable enumerableActual = actual as IEnumerable;
                IEnumerable enumerableExpected = expected as IEnumerable;

                if (enumerableActual != null && enumerableExpected != null)
                {
                    var comparer = new EnumerableEqualityComparer();
                    comparer.Equals(enumerableActual, enumerableExpected);

                    differencePosition = "Position: First difference is at position " + comparer.Position + Environment.NewLine;
                }
            }

            this.actual = actual == null ? null : ConvertToString(actual);
            this.expected = expected == null ? null : ConvertToString(expected);

            if (actual != null &&
                expected != null &&
                actual.ToString() == expected.ToString() &&
                actual.GetType() != expected.GetType())
            {
                this.actual += String.Format(" ({0})", actual.GetType().FullName);
                this.expected += String.Format(" ({0})", expected.GetType().FullName);
            }
        }
        public static void Equals___Should_return_false___When_enumerableEqualityComparerStrategy_is_SequenceEqual_and_item1_and_item2_are_not_null_and_not_equal()
        {
            // Arrange
            var systemUnderTest = new EnumerableEqualityComparer <string>(EnumerableEqualityComparerStrategy.SequenceEqual);

            var item1a = Some.ReadOnlyDummies <string>(3);
            var item1b = Some.ReadOnlyDummies <string>(3);

            var item2a = new[] { "abc", null, "def" };
            var item2b = new[] { "def", null, "abc" };

            // Act
            var actual1 = systemUnderTest.Equals(item1a, item1b);
            var actual2 = systemUnderTest.Equals(item2a, item2b);

            // Assert
            actual1.Should().BeFalse();
            actual2.Should().BeFalse();
        }
        public static void Equals___Should_return_true___When_enumerableEqualityComparerStrategy_is_UnorderedEqual_and_item1_and_item2_are_not_null_and_equal()
        {
            // Arrange
            var systemUnderTest = new EnumerableEqualityComparer <string>(EnumerableEqualityComparerStrategy.UnorderedEqual);

            var item1a = new[] { "abc", null, "def" };
            var item1b = new[] { "def", "abc", null };

            var item2a = new[] { "abc", null, "def", "abc", "ghi", null };
            var item2b = new[] { null, "ghi", null, "abc", "def", "abc" };

            // Act
            var actual1 = systemUnderTest.Equals(item1a, item1b);
            var actual2 = systemUnderTest.Equals(item2a, item2b);

            // Assert
            actual1.Should().BeTrue();
            actual2.Should().BeTrue();
        }
        public static void Equals___Should_return_true___When_enumerableEqualityComparerStrategy_is_SequenceEqual_and_item1_and_item2_are_null()
        {
            // Arrange
            var systemUnderTest = new EnumerableEqualityComparer <string>(EnumerableEqualityComparerStrategy.SequenceEqual);

            // Act
            var actual = systemUnderTest.Equals(null, null);

            // Assert
            actual.Should().BeTrue();
        }
        public static void Equals___Should_return_true___When_enumerableEqualityComparerStrategy_is_SequenceEqual_and_item1_and_item2_are_the_same_reference()
        {
            // Arrange
            var systemUnderTest = new EnumerableEqualityComparer <string>(EnumerableEqualityComparerStrategy.SequenceEqual);
            var item            = new[] { "abc", null, "def" };

            // Act
            var actual = systemUnderTest.Equals(item, item);

            // Assert
            actual.Should().BeTrue();
        }
        public static void Equals___Should_return_false___When_enumerableEqualityComparerStrategy_is_SequenceEqual_and_item1_is_not_null_and_item2_is_null()
        {
            // Arrange
            var systemUnderTest = new EnumerableEqualityComparer <string>(EnumerableEqualityComparerStrategy.SequenceEqual);
            var item1           = Some.ReadOnlyDummies <string>();

            // Act
            var actual = systemUnderTest.Equals(item1, null);

            // Assert
            actual.Should().BeFalse();
        }
        public static void Equals___Should_return_true___When_enumerableEqualityComparerStrategy_is_UnorderedEqual_and_item1_and_item2_are_empty()
        {
            // Arrange
            var systemUnderTest = new EnumerableEqualityComparer <string>(EnumerableEqualityComparerStrategy.UnorderedEqual);
            var item1           = new string[0];
            var item2           = new string[0];

            // Act
            var actual = systemUnderTest.Equals(item1, item2);

            // Assert
            actual.Should().BeTrue();
        }
        public static void Equals___Should_return_false___When_enumerableEqualityComparerStrategy_is_UnorderedEqual_and_item1_and_item2_are_not_null_and_not_equal()
        {
            // Arrange
            var systemUnderTest = new EnumerableEqualityComparer <string>(EnumerableEqualityComparerStrategy.UnorderedEqual);

            var item1 = new[] { "abc", "def", "ghi" };
            var item2 = new[] { "abc", "def", "ghi", "abc" };

            // Act
            var actual = systemUnderTest.Equals(item1, item2);

            // Assert
            actual.Should().BeFalse();
        }
예제 #10
0
 /// <summary>
 /// Equates two <see cref="EventStream" /> instances
 /// </summary>
 /// <param name="first">The first <see cref="EventStream" /> instance</param>
 /// <param name="second">The second <see cref="EventStream" /> instance</param>
 /// <returns>true if equal, otherwise false</returns>
 public static bool Equals(EventStream first, EventStream second)
 {
     return(_comparer.Equals(first, second));
 }
예제 #11
0
 /// <summary>
 /// Equates two <see cref="SingleEventTypeEventStream" /> instances
 /// </summary>
 /// <param name="first">The first <see cref="SingleEventTypeEventStream" /> instance</param>
 /// <param name="second">The second <see cref="SingleEventTypeEventStream" /> instance</param>
 /// <returns>true if equal, otherwise false</returns>
 public static bool Equals(SingleEventTypeEventStream first, SingleEventTypeEventStream second)
 {
     return(_comparer.Equals(first, second));
 }
예제 #12
0
        protected AssertActualExpectedException(object expected,
                                             object actual,
                                             string userMessage,
                                             bool skipPositionCheck = false)
            : base(userMessage)
        {
            if (!skipPositionCheck)
            {
                var enumerableActual = actual as IEnumerable;
                var enumerableExpected = expected as IEnumerable;

                if (enumerableActual != null && enumerableExpected != null)
                {
                    var comparer = new EnumerableEqualityComparer();
                    comparer.Equals(enumerableActual, enumerableExpected);

                    differencePosition = "Position: First difference is at position " + comparer.Position + Environment.NewLine;
                }
            }

            Actual = actual == null ? null : ConvertToString(actual);
            Expected = expected == null ? null : ConvertToString(expected);

            if (actual == null || expected == null || actual.ToString() != expected.ToString() ||
                actual.GetType() == expected.GetType()) return;
            Actual += $" ({actual.GetType().FullName})";
            Expected += $" ({expected.GetType().FullName})";
        }
예제 #13
0
 /// <summary>
 /// Equates two <see cref="SingleEventTypeEventStream" /> instances.
 /// </summary>
 /// <param name="left">The left <see cref="SingleEventTypeEventStream" /> instance.</param>
 /// <param name="right">The right <see cref="SingleEventTypeEventStream" /> instance.</param>
 /// <returns>true if equal, otherwise false.</returns>
 public static bool Equals(SingleEventTypeEventStream left, SingleEventTypeEventStream right)
 {
     return(_comparer.Equals(left, right));
 }