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()); }
public void LastResult_ExternalWorkReturnedFalse_IsFalse() { using (var sut = new AbortableWorker(() => false)) { sut.Start(); sut.ResumeWork(); sut.WaitForWorkDone(); Assert.False(sut.LastRunResult); } }
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)); } }