コード例 #1
0
 public void WorkDelegate_IsCalledOnceOnDoWork()
 {
     var workMock = PrepareExternalWorkMock();
     using (var sut = new AbortableWorker(workMock.Object.DoWork))
     {
         sut.Start();
         sut.ResumeWork();
         sut.WaitForWorkDone(Timeout.Infinite);
     }
     workMock.Verify(x => x.DoWork(), Times.Once());
 }
コード例 #2
0
 public void LastResult_ExternalWorkReturnedFalse_IsFalse()
 {
     using (var sut = new AbortableWorker(() => false))
     {
         sut.Start();
         sut.ResumeWork();
         sut.WaitForWorkDone();
         Assert.False(sut.LastRunResult);
     }
 }
コード例 #3
0
        public void OnDoWorkFalse_Aborts()
        {
            var workMock = PrepareExternalWorkMock(0);
            using (var sut = new AbortableWorker(workMock.Object.DoWork))
            {
                sut.Start();
                sut.ResumeWork();
                sut.WaitForWorkDone(Timeout.Infinite);

                Assert.True(sut.ThreadInstance.Join(Timeout.Infinite));
            }
        }