コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }