public void ShouldSubscribeToFirstChanceExceptionOnConstructionCallAbstractMethodOnEventAndUnsubscribeOnDisposal() { FirstChanceException initializationHandler = Substitute.ForPartsOf <FirstChanceException>(); using (initializationHandler) { Assert.Equal(initializationHandler, FirstChanceExceptionSubscribers.Target); Exception exception = new Exception(); FirstChanceExceptionSubscribers(AppDomain.CurrentDomain, new FirstChanceExceptionEventArgs(exception)); Assert.Equal(1, initializationHandler.ReceivedCalls().Count()); Assert.Equal(initializationHandler, initializationHandler.ReceivedCalls().Single().Target()); Assert.Equal(1, initializationHandler.ReceivedCalls().Single().GetArguments().Length); Assert.IsType <FirstChanceExceptionEventArgs>(initializationHandler.ReceivedCalls().Single().GetArguments()[0]); Assert.Equal(exception, ((FirstChanceExceptionEventArgs)initializationHandler.ReceivedCalls().Single().GetArguments()[0]).Exception); } Assert.Null(FirstChanceExceptionSubscribers); }
internal static void OnFirstChanceException(object e) { FirstChanceException?.Invoke(/* AppDomain */ null, new FirstChanceExceptionEventArgs((Exception)e)); }
public void default_value_is_returned_without_exception() { Actual.ShouldEqual(Expected); FirstChanceException.ShouldBeNull(); }