Closed Dorus closed 1 year ago
Thanks for the report, I'll have a look!
I ended up doing the check with FluentAssertions like this:
var log = _loggerFactory.Sink.LogEntries.Select(e => e.Properties).Should().BeEquivalentTo(new[] {
new Dictionary<string, string>
{
{ "{OriginalFormat}", "File {fileName} is not an xml file." },
{ "fileName", "bla.txt" }
}
});
Same for me 2.4.2 working , 2.5.0 not. Testing on .NET8.0 latest preview with async tests.
@alefranz Maybe the following can help your investigation a bit:
I just had the same problem while debugging Roslyn Analyzer Tests and found out that between xUnit 2.4.2 and 2.5.0 the public interface of EqualException changed
. This diff clearly shows the difference in the constructor, which leads to the MissingMethodException.
For MELT, the problem is in those lines: https://github.com/alefranz/MELT/blob/b4fbc549609d35266b932d6beabbde2f2a47c7f0/src/MELT.Xunit/LoggingAssert.cs#L53-L55
It looks like
EqualException.ForMismatchedValues(expected, actual)
is the new way to construct such an Exception now.
As a comparison the Roslyn Analyzer Testing problem stems from: https://github.com/dotnet/roslyn-sdk/blob/42ce3944fc4488a7ebfbf1f8d395c66808577d77/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Testing.Verifiers.XUnit/EqualWithMessageException.cs#L12-L16
Released 0.9.0. Any feedback is appreciated.
Thanks for the investigation @bemayr . I went the easy route for now and built the base exception, manually crafting the message. Given the discussion on https://github.com/dotnet/roslyn-sdk/issues/1099, it seems like the best solution is to drop the dependency to the assert package. I have some refactoring in progress, so will consider dropping it as part of that.
I updated my xUnit packages today, and got this exception:
on calling this code: