Hello,
You could do it using delegates in your unit tests.
for example:
[TestMethod]
public void EventShouldBeRaised()
{
ClassToTest classToTest = new ClassToTest();
bool eventRaised = false;
classToTest.EventRaised += delegate(object sender, ClassToTestEventArgs e)
{
eventRaised = true;
};
classToTest.Property1 = "somthing";
Assert.AreEqual(eventRaised, true);
}
[TestMethod]
public void EventShouldNotBeRaised()
{
ClassToTest classToTest = new ClassToTest();
bool eventRaised = false;
classToTest.EventRaised += delegate(object sender, ClassToTestEventArgs e)
{
eventRaised = true;
};
classToTest.AnotherProperty = "somthing";
Assert.AreEqual(eventRaised, false);
}
Valery.