예제 #1
0
        public void CanAssertEqualityFailBasedOnLocalDefinedObjectAndOnlyAssertNonDefaultProperties()
        {
            var toTest = new PropertyTest
            {
                Id        = 7,
                Name      = "Foobar",
                Age       = 42,
                Locations =
                {
                    "Europe",
                    "Asia"
                }
            };

            var expected = new PropertyTest
            {
                Name = "Fooba"
            };

            var e = Assert.Throws <VerificationException>(() => toTest.Verify(() => expected));

            Assert.Equal(nameof(PropertyTest.Name), e.Target);
            Assert.Equal("Fooba", e.ExpectedValue);
            Assert.Equal("Foobar", e.ActualValue);
        }
예제 #2
0
        public void CanAssertEqualityBasedOnObject()
        {
            var toTest = new PropertyTest
            {
                Id        = 7,
                Name      = "Foobar",
                Age       = 42,
                Locations =
                {
                    "Europe",
                    "Asia"
                }
            };

            toTest.Verify(() => new PropertyTest
            {
                Name = "Foobar"
            });
        }
예제 #3
0
        public void CanAssertEqualityBasedOnLocalDefinedObjectAndOnlyAssertNonDefaultProperties()
        {
            var toTest = new PropertyTest
            {
                Id        = 7,
                Name      = "Foobar",
                Age       = 42,
                Locations =
                {
                    "Europe",
                    "Asia"
                }
            };

            var expected = new PropertyTest
            {
                Name = "Foobar"
            };

            toTest.Verify(() => expected);
        }
예제 #4
0
        public void CanAssertFailEqualityBasedOnObject()
        {
            var toTest = new PropertyTest
            {
                Id        = 7,
                Name      = "Foobar",
                Age       = 42,
                Locations =
                {
                    "Europe",
                    "Asia"
                }
            };

            var e = Assert.Throws <VerificationException>(() => toTest.Verify(() => new PropertyTest
            {
                Name = "Fooba"
            }));

            Assert.Equal(nameof(PropertyTest.Name), e.Target);
            Assert.Equal("Fooba", e.ExpectedValue);
            Assert.Equal("Foobar", e.ActualValue);
        }
예제 #5
0
        public void CanAssertEqualityFailIndirectlyBasedOnLocalDefinedObject()
        {
            var toTest = new PropertyTest
            {
                Id        = 7,
                Name      = "Foobar",
                Age       = 42,
                Locations =
                {
                    "Europe",
                    "Asia"
                }
            };

            var expected = new PropertyTest
            {
                Name = "Fooba"
            };

            var e = Assert.Throws <VerificationException>(() => toTest.Verify(p => p.Name == expected.Name));

            Assert.Equal("p.Name == expected.Name", e.Message);
        }