Replies: 1 comment 2 replies
-
Have you looked at how Prism tests the filter? |
Beta Was this translation helpful? Give feedback.
2 replies
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.
-
Not sure if this is the best place to ask, but bored of getting replies on stack overflow of "Why are you even bothering to test that". Because my company has an inane idea about 100% coverage, like a load of them do...
I've found a way to test my event aggregator subscriptions using mstest and moq via the following, I apologize but I need to manually copy the code over so it's poorly formatted and may be missing a bit.
I then test the callback with
callback.Invoke(new MyEventArgs("Test"));
This all works fine, however I'm running into two issues.
First. If my subscription has a filter on it. For example x => x.Name == Name then I do not get the code coverage increase I'm expecting, I'm assuming this is because the filter isn't being tested (removing the filter my test coverage increases)
However I am not sure how to write a test with the filter involved.
I've tried setting the predicate line to args => args.Name == "Test"; but then my callback gets set to null.
Just wondering if anyone has had any luck setting up a unit test for the filter portion of the event aggregator subscription.
Beta Was this translation helpful? Give feedback.
All reactions