-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
I use my own implementation of Exception which implements a interface with a Message-Property. This property is of another type.
Reproduction Steps
[Fact]
public void Test()
{
var instance = new MyClass()
{
MyError = 42,
};
var other = new MyClass()
{
MyError = 42,
};
instance.Should().BeEquivalentTo(other);
}
public class MyClass : Exception, IMyInterface
{
public int MyError { get; set; }
int IMyInterface.Message => MyError;
}
public interface IMyInterface
{
int Message { get; }
}Expected behavior
The test passes.
Actual behavior
The test failes with the message:
Message:
Expected property instance.MyNamespace.IMyInterface.Message to be System.String, but found System.Int32.
With configuration:
- Use declared types and members
- Compare enums by value
- Compare tuples by their properties
- Compare anonymous types by their properties
- Compare records by their members
- Include non-browsable members
- Match member by name (or throw)
- Be strict about the order of items in byte arrays
- Without automatic conversion.
Stack Trace:
XUnit2TestFramework.Throw(String message)
TestFrameworkProvider.Throw(String message)
CollectingAssertionStrategy.ThrowIfAny(IDictionary`2 context)
AssertionScope.Dispose()
EquivalencyValidator.AssertEquality(Comparands comparands, EquivalencyValidationContext context)
ObjectAssertions`2.BeEquivalentTo[TExpectation](TExpectation expectation, Func`2 config, String because, Object[] becauseArgs)
ObjectAssertions`2.BeEquivalentTo[TExpectation](TExpectation expectation, String because, Object[] becauseArgs)
MyTestClass.Test() line 426
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Regression?
In 6.12.0 it worked by with 6.12.1 it is failing.
Known Workarounds
No response
Configuration
net8.0
FluentAssertions 6.12.1
Other information
No response
Are you willing to help with a pull-request?
No
warappa