예제 #1
0
        public void Should_NotAllowReEnter_When_WuStateAsyncJobIsDisposed()
        {
            WuStateAsyncJob state = new WuStateAsyncJobProxy(WuStateId.Downloading, "name", 1);

            state.Dispose();
            state.EnterState(new WuStateReady());
        }
예제 #2
0
 public void Should_UpdateRunningIndicator_When_StartAndAbortTimer()
 {
     using (WuStateAsyncJobProxy state = new WuStateAsyncJobProxy(WuStateId.Downloading, "name", 10000))
     {
         Assert.IsFalse(state.IsRunning);
         state.EnterState(new WuStateReady());
         Assert.IsTrue(state.IsRunning);
         state.Abort();
         Assert.IsFalse(state.IsRunning);
     }
 }
예제 #3
0
        public void Should_CallRequestAbort_When_AbortJob()
        {
            var job = MoqFactory.Create <WuApiJobAdapter>(MockBehavior.Loose);

            job.Setup(j => j.RequestAbort());
            using (WuStateAsyncJobProxy state = new WuStateAsyncJobProxy(WuStateId.Downloading, "name", 10000))
            {
                state.Job = job.Object;
                state.EnterState(new WuStateReady());
                state.Abort();
                job.Verify(j => j.RequestAbort(), Times.Once);
            }
        }
예제 #4
0
        public void Should_CallOnTimeout_When_TimeRunsOut()
        {
            int timeout = 1;
            WuStateAsyncJobProxy state = new WuStateAsyncJobProxy(WuStateId.Downloading, "name", timeout);

            state.EnterState(new WuStateReady());

            if (!state.OnTimeoutSignal.WaitOne((int)(timeout * 1000 * 1.5)))
            {
                Assert.Fail($"OnTimeout was not called");
            }
            Assert.IsFalse(state.IsRunning);
            state.Dispose();
        }