I have defined two events with custom event arguments and associated raising methods. Now I wonder what and how the event should be tested. How should I analyze the code to find candidates for unit testing?
I have defined two events with custom event arguments and associated raising methods. Now
Share
The way I test events is as follows:
Suppose this is your object:
Therefore your Subject Under Test is:
MyEventRaiserand you want to test the methodProcess. You need to test that the event is raised when certain conditions are met, otherwise, the event should not be raised.To do it, I use this framework (that I use always in my tests) FluentAssertions, this framewrok can be used with any test engine like MSTest, NUnit, MSpec, XUnit, etc
The tests look like:
You need to use the following namespaces: