-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
When doing #2399 I found that these four methods in TypeAssertions are not guarded against being wrapped in an AssertionScope.
HaveExplicitPropertyNotHaveExplicitPropertyHaveExplicitMethodNotHaveExplicitMethod
See how we call Should().Implement() and the make the next assertion without any guards.
fluentassertions/Src/FluentAssertions/Types/TypeAssertions.cs
Lines 976 to 984 in f4c3d56
| Subject.Should().Implement(interfaceType, because, becauseArgs); | |
| var explicitlyImplementsProperty = Subject.HasExplicitlyImplementedProperty(interfaceType, name); | |
| Execute.Assertion | |
| .BecauseOf(because, becauseArgs) | |
| .ForCondition(explicitlyImplementsProperty) | |
| .FailWith( | |
| $"Expected {Subject} to explicitly implement {interfaceType}.{name}{{reason}}, but it does not."); |
Reproduction Steps
var act = () =>
{
using var _ = new AssertionScope();
typeof(int).Should().HaveExplicitProperty(typeof(IExplicitInterface), "Foo");
};
act.Should().Throw<XunitException>()
.WithMessage("Expected type System.Int32 to*implement IExplicitInterface.Foo, but it does not.");Expected behavior
pass
Actual behavior
Expected exception message to match the equivalent of "Expected type System.Int32 to*implement IExplicitInterface.Foo, but it does not.", but "Expected type System.Int32 to implement interface FluentAssertions.Specs.Types.IExplicitInterface, but it does not.
Expected System.Int32 to explicitly implement FluentAssertions.Specs.Types.IExplicitInterface.Foo, but it does not.
" does not.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Are you willing to help with a pull-request?
Yes, please assign this issue to me.
dennisdoomen