-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A.CallTo(() => ...).MustHaveHappened(2, Times.Exactly) fails for unknown reason after upgrading to netcoreapp3.0 #1650
Comments
Hi, @tonitassimo. Sorry you're having problems. What version of FakeItEasy are you using? Have you upgraded it lately? If so, from what? Reading your output, it seems that If this is the case, I'm not sure FakeItEasy is misbehaving. Is it possible that the explicit interface implementation is new to the logger with the upgrade to netcoreapp3.0? |
That's because the method that is called is actually Unfortunately, A.CallTo(logger).Where(call => call.Method.Name == "Log" && call.GetArgument<LogLevel>(0) == LogLevel.Warning)
.MustHaveHappened(2, Times.Exactly); It kinda sucks, but I don't see any better alternative |
Thanks for your quick answers! I think FakeItEasy isn't misbehaving. I'll try out your advices! |
As for why it started failing in 3.0, you have to look at the implementation of LoggerExtensions. In 2.2, In 3.3, Also, |
See also dotnet/extensions#1319 |
Many thanks for your help. Your workaround definitely works :) if we find any other way, I'll let you know. |
Closing this, since there's a workaround that works for @tonitassimo. In the future, we might want to introduce some kind of "catch-all" type to deal with that kind of thing. Maybe something like this:
We already have an issue to improve the experience when working with generics: #743 |
Thanks for your help @thomaslevesque |
I am trying to mock it using the Invokes, but i can't because FormattedLogValues is internal.. :\ |
I'm sorry, @gds03. Can you expand on that? You're trying to mock |
@gds03 have you tried the workaround suggested above? |
HI Guys, I have sorted out using object.
I wanted to intercept the log method to log to another place in my tests, with the above code it just works OK :) |
After updating from netcoreapp2.2 to netcoreapp3.0 we're having some issues with fake it easy. I don't know whether or not it's due to fake it easy or netcoreapp. We're using fake it easy 5.2.0.
This is what we are trying to test:
We just want to make sure that the logger is called two times with LogLevel.Warning.
The relevant part of the result is shown
in the attached filebelow.We're getting the two expected calls. The only difference we can see is:
expected: [...]
ILogger.Log[System.Object]
[...]actual: [...]
ILogger[TXS.Analytics.Export.Interface.IExporter].Log[Microsoft.Extensions.Logging.FormattedLogValues]
[...]Until we upgraded from netcoreapp2.2 to netcoreapp3.0 this worked perfectly fine.
Maybe someone has an idea or has encountered similar problems?
Many thanks in advance! :)
The text was updated successfully, but these errors were encountered: