public void When_a_property_is_internal_it_should_be_excluded_from_the_comparison() { // Arrange var actual = new ClassWithInternalProperty { PublicProperty = "public", InternalProperty = "internal", ProtectedInternalProperty = "internal" }; var expected = new ClassWithInternalProperty { PublicProperty = "public", InternalProperty = "also internal", ProtectedInternalProperty = "also internal" }; // Act / Assert actual.Should().BeEquivalentTo(expected); }
public void When_a_property_is_internal_and_it_should_be_included_it_should_fail_the_assertion() { // Arrange var actual = new ClassWithInternalProperty { PublicProperty = "public", InternalProperty = "internal", ProtectedInternalProperty = "internal" }; var expected = new ClassWithInternalProperty { PublicProperty = "public", InternalProperty = "also internal", ProtectedInternalProperty = "also internal" }; // Act Action act = () => actual.Should().BeEquivalentTo(expected, options => options.IncludingInternalProperties()); // Assert act.Should().Throw <XunitException>().WithMessage("*InternalProperty*also internal*internal*ProtectedInternalProperty*"); }