Is it possible to Raise events based on a matched type?
denxorz opened this issue · 0 comments
denxorz commented
Is it possible to raise an event based on a type found by It.Is? Put an example in the test below.
[TestCase]
public void Raise_NonStaticEventBasedOnMatch_OriginalEventInvokesSubscribers()
{
int invocationCount = 0;
Smock.Run(context =>
{
ClassWithEvents instance = new ClassWithEvents();
instance.TheEvent += (sender, args) => ++invocationCount;
instance.RaiseTheEvent(EventArgs.Empty);
context.Raise(() => It.IsAny<ClassWithEvents>().TheEvent += null, () => It.IsAny<ClassWithEvents>().TheEvent -= null, EventArgs.Empty);
});
Assert.AreEqual(2, invocationCount);
}
Thanks for the great plugin.
Dennis