public void StopDoesNotRaiseStoppingEventDuringImmediateShutdown() { var service = new WebApplicationLifecycle(); bool eventFired = false; service.Stopping += (sender, args) => eventFired = true; service.Stop(true); Assert.IsFalse(eventFired); }
public void StopDoesNotCrashCrashWithoutStoppingEventHandlers() { var service = new WebApplicationLifecycle(); Exception exception = null; try { service.Stop(false); } catch (Exception ex) { exception = ex; } Assert.IsNull(exception); }
public void StopRaisesStoppingEventWhenWebHostingEnvironmentNotifiesRegisteredObjectsAboutShutdown() { var service = new WebApplicationLifecycle(); object stoppingSender = null; ApplicationStoppingEventArgs stoppingArgs = null; service.Stopping += (sender, args) => { stoppingSender = sender; stoppingArgs = args; }; service.Stop(false); Assert.NotNull(stoppingSender); Assert.NotNull(stoppingArgs); }
public void StopRaisesStoppingEventWhenWebHostingEnvironmentNotifiesRegisteredObjectsAboutShutdown() { var service = new WebApplicationLifecycle(); object stoppingSender = null; ApplicationStoppingEventArgs stoppingArgs = null; service.Stopping += (sender, args) => { stoppingSender = sender; stoppingArgs = args; }; service.Stop(false); Assert.IsNotNull(stoppingSender); Assert.IsNotNull(stoppingArgs); }
public void StopInvokesAsyncStoppingEventHandlersOnCurrentThreadToPreventHostingEnvironmentFromStoppingThreadPool() { TaskScheduler stoppingTaskScheduler = null; var service = new WebApplicationLifecycle(); service.Stopping += (sender, args) => { args.Run(() => { stoppingTaskScheduler = TaskScheduler.Current; return(TaskEx.FromResult <object>(null)); }); }; service.Stop(false); AssertEx.IsType <CurrentThreadTaskScheduler>(stoppingTaskScheduler); }
public void StopDoesNotCrashCrashWithoutStoppingEventHandlers() { var service = new WebApplicationLifecycle(); Exception exception = null; try { service.Stop(false); } catch (Exception ex) { exception = ex; } Assert.Null(exception); }
public void StopDoesNotRaiseStoppingEventDuringImmediateShutdown() { var service = new WebApplicationLifecycle(); bool eventFired = false; service.Stopping += (sender, args) => eventFired = true; service.Stop(true); Assert.False(eventFired); }
public void StopInvokesAsyncStoppingEventHandlersOnCurrentThreadToPreventHostingEnvironmentFromStoppingThreadPool() { TaskScheduler stoppingTaskScheduler = null; var service = new WebApplicationLifecycle(); service.Stopping += (sender, args) => { args.Run(() => { stoppingTaskScheduler = TaskScheduler.Current; return TaskEx.FromResult<object>(null); }); }; service.Stop(false); Assert.IsType<CurrentThreadTaskScheduler>(stoppingTaskScheduler); }