public void When_an_assertion_on_two_objects_fails_it_should_show_the_properties_of_the_class() { // Arrange var subject = new SomeDto { Age = 37, Birthdate = 20.September(1973), Name = "Dennis" }; var other = new SomeDto { Age = 2, Birthdate = 22.February(2009), Name = "Teddie" }; // Act Action act = () => subject.Should().Be(other); // Assert act.Should().Throw <XunitException>().WithMessage( "Expected subject to be*FluentAssertions*SomeDto*{*Age = 2*Birthdate = <2009-02-22>*" + " Name = \"Teddie\"*}, but found*FluentAssertions*SomeDto*{*Age = 37*" + " Birthdate = <1973-09-20>*Name = \"Dennis\"*}."); }
public void When_typed_object_satisfies_predicate_it_should_not_throw() { // Arrange var someObject = new SomeDto { Name = "Dennis Doomen", Age = 36, Birthdate = new DateTime(1973, 9, 20) }; // Act / Assert someObject.Should().Match <SomeDto>(o => o.Age > 0); }
public void When_a_typed_object_does_not_match_the_predicate_it_should_throw() { // Arrange var someObject = new SomeDto { Name = "Dennis Doomen", Age = 36, Birthdate = new DateTime(1973, 9, 20) }; // Act Action act = () => someObject.Should().Match((SomeDto d) => d.Name.Length == 0, "it is not initialized yet"); // Assert act.Should().Throw <XunitException>().WithMessage( "Expected someObject to match (d.Name.Length == 0) because it is not initialized yet*"); }