IMessengerExtensions.Send blocks unit testing #1113
Unanswered
mikeKuester
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm migrating a legacy app from MvvmLight to CommunityToolkit. Most parts are easy to handle, but now all unit tests which check the IMessenger calls fail, because of the IMessengerExtensions which use the internal
Unit
type.I use .NET Framework 4.8.x and Moq for unit testing.
There is a messenger send in a method:
And the unit tests for the method contains something like this:
The extension method
Send<TMessage>(this IMessenger messenger, TMessage message)
uses the internal typeUnit
, which I can't use in my units tests to see if a mock has the right invocations.dotnet/src/CommunityToolkit.Mvvm/Messaging/IMessengerExtensions.cs
Line 422 in 657c697
I can't write a working unit test:
Why is it not possible to use a public type in the extension method for the
TToken
?The extension method should make it easy to use the Send method if you don't need different channels. However, the current implementation prevents this when I want to test my code. Or did I miss here something?
Thanks,
Mike
Update: It's not only the send method, all methods have the same problem.
Beta Was this translation helpful? Give feedback.
All reactions