Beispiel #1
0
        public void ShouldBeAbleToHandleComparingObjectsWithPropertiesWithArguments()
        {
            var x = new HasPropertiesWithArguments();
            var y = new HasPropertiesWithArguments();

            DeepAssert.AreEqual(x, y);
        }
Beispiel #2
0
        public void KitchenSink()
        {
            var object1 = new
            {
                A = 1,
                B = UriKind.Absolute,
                C = new List <int> {
                    1, 2, 3
                },
                Float  = 1.111_111_8f,
                Double = 1.111_111_111_111_118d,
                Inner  = new
                {
                    X = 1,
                    Y = 2,
                    Z = 3
                },
                Set        = new[] { 3, 4, 2, 1 },
                Dictionary = new Dictionary <int, int>
                {
                    { 2, 3 },
                    { 123, 234 },
                    { 345, 456 }
                }
            };

            var object2 = new
            {
                A      = 1,
                B      = "Absolute",
                C      = new[] { 1, 2, 3 },
                Float  = 1.111_111_9m,
                Double = 1.111_111_111_111_119m,
                Inner  = new TestType
                {
                    X = 1,
                    Y = 3,
                    Z = 3
                },
                Set = new HashSet <int> {
                    1, 2, 3, 4
                },
                Dictionary = new Dictionary <int, int>
                {
                    { 123, 234 },
                    { 345, 456 },
                    { 2, 3 }
                }
            };

            var comparison = new ComparisonBuilder()
                             .IgnoreProperty <TestType>(x => x.Y)
                             .Create();

            DeepAssert.AreEqual(object1, object2, comparison);
        }
Beispiel #3
0
        public static void When_exposing_internals_similar_objects_are_considered_the_same()
        {
            var expected = new ClassWithPrivates(123)
            {
                Id       = 234,
                Name     = "Joe",
                Internal = "???"
            };

            var actual = new ClassWithPrivates(123)
            {
                Id       = 234,
                Name     = "Joe",
                Internal = "???"
            };

            var comparison = new ComparisonBuilder()
                             .ExposeInternalsOf <ClassWithPrivates>()
                             .Create();

            DeepAssert.AreEqual(actual, expected, comparison);
        }
        public void InconclusiveResult()
        {
            var comparison = new EchoComparison(ComparisonResult.Inconclusive);

            DeepAssert.AreEqual(a, b, comparison);
        }
        public void PassResult()
        {
            var comparison = new EchoComparison(ComparisonResult.Pass);

            DeepAssert.AreEqual(a, b, comparison);
        }