public void When_a_field_is_internal_it_should_be_excluded_from_the_comparison() { // Arrange var actual = new ClassWithInternalField { PublicField = "public", InternalField = "internal", ProtectedInternalField = "internal" }; var expected = new ClassWithInternalField { PublicField = "public", InternalField = "also internal", ProtectedInternalField = "also internal" }; // Act / Assert actual.Should().BeEquivalentTo(expected); }
public void When_a_field_is_internal_and_it_should_be_included_it_should_fail_the_assertion() { // Arrange var actual = new ClassWithInternalField { PublicField = "public", InternalField = "internal", ProtectedInternalField = "internal" }; var expected = new ClassWithInternalField { PublicField = "public", InternalField = "also internal", ProtectedInternalField = "also internal" }; // Act Action act = () => actual.Should().BeEquivalentTo(expected, options => options.IncludingInternalFields()); // Assert act.Should().Throw <XunitException>().WithMessage("*InternalField*also internal*internal*ProtectedInternalField*"); }