I want to write a test against a property that calls a PropertyChanged event handler when no class has subscribed to the event as a test to insure that the event handler does not call a null EventHandler delagate. The test is utilizing the NUnit framework. Here is the test I have written so far:
public void PropertyChangedEventDoesNotFireWithoutHandlers()
_instance.IsSelected = true;
I figure that this test will fail, if an exception is generated if the PropertyChanged event handler tries to call a null delagate, so the Assert.Pass() statement would never be reached.
In the case of the instantiated class IsSelected is false by default, so setting it to true causes the event to fire. (I've testing that with another test method.) And dotCoverage shows that the relavant code in the event handler is covered by the test. But the test itself is only marked as 3/4 covered. The uncovered code according to highlighting is the last bracket character.
I have a couple questions about this. First why does dotCover mark the method as 3/4 covered? Second is there a better way to write the test, so that the whole test is covered?