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); }
public void CanAssertEqualityBasedOnObject() { var toTest = new PropertyTest { Id = 7, Name = "Foobar", Age = 42, Locations = { "Europe", "Asia" } }; toTest.Verify(() => new PropertyTest { Name = "Foobar" }); }
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); }
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); }
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); }