コード例 #1
0
        public async Task CanCancelWorkItem()
        {
            var workItemDto = new WorkItem();

            workItemDto.Id                  = 2;
            workItemDto.AdminGroupId        = null;
            workItemDto.CompletionMode      = Api.Models.CompletionMode.AnyAssigned;
            workItemDto.DescriptionMarkup   = "<h1>header</h1>";
            workItemDto.Location            = "location";
            workItemDto.Name                = "name";
            workItemDto.PatrolId            = 1;
            workItemDto.RecurringWorkItemId = null;
            workItemDto.ScheduledAt         = new DateTime(2001, 1, 1);
            int userId = 50;

            _workItemRepository.Setup(x => x.GetWorkItem(workItemDto.Id))
            .Returns(Task.FromResult(workItemDto))
            .Verifiable();

            var now = new DateTimeOffset(2001, 1, 1, 0, 0, 0, new TimeSpan());

            _systemClockMock.Setup(x => x.UtcNow).Returns(now);

            _workItemRepository.Setup(x => x.UpdateWorkItem(It.Is <WorkItem>(y => y.CanceledAt == now.UtcDateTime)))
            .Verifiable();

            await _workItemService.CancelWorkItem(workItemDto.Id, userId);

            _workItemRepository.Verify();
        }