How do I verify a non-generic event was raised? #2772
-
I know there's public class Testing
{
public static void RaisesEvent(
Action<EventHandler> attach,
Action<EventHandler> detach,
Action testCode)
{
bool isEventRaised = false;
var eventHandler = new EventHandler(delegate
{
isEventRaised = true;
});
attach(eventHandler);
testCode();
detach(eventHandler);
Assert.True(isEventRaised);
}
} Is there a way to achieve that using a standard xunit tools? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Yep, this is trivial for me to add. Note: these will be Therefore, if you want to test for an exact type, you will need to run two assertions: |
Beta Was this translation helpful? Give feedback.
Fixed in #2773.