コード例 #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);
        }