public void Do_work_item() { // Arrange var batchedWorkItem = new BatchedWorkItem(_workBatchMock.Object, _workItemMock.Object); // Act batchedWorkItem.Do(_cancellationToken); // Assert _workItemMock.Verify(x => x.Do(_cancellationToken), Times.Once); }
public void Pass_result_to_batch() { // Arrange var batchedWorkItem = new BatchedWorkItem(_workBatchMock.Object, _workItemMock.Object); var result = new WorkItemResult(WorkStatus.Successful); _workItemMock.Setup(x => x.Do(It.Is <CancellationToken>(y => y == _cancellationToken))).Returns(result); // Act batchedWorkItem.Do(_cancellationToken); // Assert _workBatchMock.Verify(x => x.DoFinally(result, _cancellationToken), Times.Once); }
public void Execute_function_when_created_with_lambda_overload() { // Arrange var functionMockCalled = false; Func <CancellationToken, WorkItemResult> functionMock = cancellationToken => { functionMockCalled = true; return(new WorkItemResult(WorkStatus.Successful)); }; var batchedWorkItem = new BatchedWorkItem(_workBatchMock.Object, functionMock); // Act batchedWorkItem.Do(_cancellationToken); // Assert functionMockCalled.Should().BeTrue(); }