Esempio n. 1
0
        public async Task ThrowsUnauthorizedWhenNotAuthorized(Generated.JobStatusUpdateTypeCode updateCode, string otherTypeCode)
        {
            // arrange
            var expectedWorkOrder = CreateWorkOrder();

            _currentUserServiceMock.SetSecurityGroup(UserGroups.Contractor, false);
            _currentUserServiceMock.SetSecurityGroup(UserGroups.ContractManager, false);
            _currentUserServiceMock.SetSecurityGroup(UserGroups.Agent, false);

            var workOrderCompleteRequest = CreateRequest(expectedWorkOrder.Id);

            workOrderCompleteRequest.JobStatusUpdates = new List <Generated.JobStatusUpdates>
            {
                new Generated.JobStatusUpdates
                {
                    TypeCode = updateCode, OtherType = otherTypeCode, Comments = "expectedComment"
                }
            };

            // act
            Func <Task> act = () => _classUnderTest.Execute(workOrderCompleteRequest);

            (await act.Should().ThrowAsync <UnauthorizedAccessException>())
            .Which.Message.Should().BeOneOf(new List <string>
            {
                Resources.NotAuthorisedToCancel, Resources.NotAuthorisedToClose
            });
        }
Esempio n. 2
0
        public async Task OperativeCanCompleteJobWhenAssigned(Generated.JobStatusUpdateTypeCode updateCode, string otherTypeCode, WorkStatusCode expectedStatus)
        {
            const string expectedPayroll = "payrollNumber";

            _currentUserServiceMock.SetUser("id", "*****@*****.**", "operative", null, null, null, expectedPayroll);
            _currentUserServiceMock.SetSecurityGroup(UserGroups.Contractor, false);
            _currentUserServiceMock.SetSecurityGroup(UserGroups.ContractManager, false);
            _currentUserServiceMock.SetSecurityGroup(UserGroups.Agent, false);
            _currentUserServiceMock.SetSecurityGroup(UserGroups.Operative, true);
            var assignedOperatives = new List <Operative>
            {
                new Operative {
                    PayrollNumber = expectedPayroll
                }
            };
            var woGenerator = CreateGenerator()
                              .AddValue(assignedOperatives, (WorkOrder wo) => wo.AssignedOperatives);
            var expectedWorkOrder        = CreateWorkOrder(woGenerator);
            var workOrderCompleteRequest = CreateRequest(expectedWorkOrder.Id);

            workOrderCompleteRequest.JobStatusUpdates = new List <Generated.JobStatusUpdates>
            {
                new Generated.JobStatusUpdates
                {
                    TypeCode = updateCode, OtherType = otherTypeCode, Comments = "expectedComment"
                }
            };

            await _classUnderTest.Execute(workOrderCompleteRequest);

            _repairsGatewayMock.Verify(x => x.UpdateWorkOrderStatus(expectedWorkOrder.Id, expectedStatus));
        }
Esempio n. 3
0
        public async Task ContractorUpdatesWorkOrderStatusNoAccess()
        {
            // arrange
            const string Comment             = "expectedComment";
            DateTime     jobStatusUpdateTime = DateTime.Now;
            const Generated.JobStatusUpdateTypeCode NoAccess = Generated.JobStatusUpdateTypeCode.DeniedAccess_70;
            WorkStatusCode expectedNewStatus = WorkStatusCode.NoAccess;

            _currentUserServiceMock.SetSecurityGroup(UserGroups.Contractor, true);
            var expectedWorkOrder        = CreateWorkOrder();
            var workOrderCompleteRequest = CreateRequest(expectedWorkOrder.Id);

            workOrderCompleteRequest.JobStatusUpdates = new List <Generated.JobStatusUpdates>
            {
                new Generated.JobStatusUpdates
                {
                    TypeCode = NoAccess, Comments = Comment, EventTime = jobStatusUpdateTime
                }
            };

            // act
            await _classUnderTest.Execute(workOrderCompleteRequest);

            // assert

            var lastWorkOrderComplete = _workOrderCompletionGatewayMock.LastWorkOrderComplete;

            _repairsGatewayMock.Verify(rgm => rgm.UpdateWorkOrderStatus(expectedWorkOrder.Id, expectedNewStatus));
            lastWorkOrderComplete.JobStatusUpdates.Single().Comments.Should().Be(Resources.WorkOrderNoAccessPrefix + $"{jobStatusUpdateTime:dd MMMM yyyy HH:mm} " + Comment);
        }
Esempio n. 4
0
 private static JobStatusUpdate CreateJobStatusUpdateRequest
     (WorkOrder workOrder, Generated.JobStatusUpdateTypeCode jobStatus)
 {
     return(new JobStatusUpdate
     {
         RelatedWorkOrder = workOrder,
         TypeCode = jobStatus,
         MoreSpecificSORCode = new WorkElement
         {
             Trade = new List <Trade>(),
             RateScheduleItem = new List <RateScheduleItem>()
         }
     });
 }
Esempio n. 5
0
        public async Task ThrowsExceptionWhenNotValidUpdateType(Generated.JobStatusUpdateTypeCode typeCode, string otherTypeCode)
        {
            // arrange
            var expectedWorkOrder        = CreateWorkOrder();
            var workOrderCompleteRequest = CreateRequest(expectedWorkOrder.Id);

            workOrderCompleteRequest.JobStatusUpdates = new List <Generated.JobStatusUpdates>
            {
                new Generated.JobStatusUpdates
                {
                    TypeCode = typeCode, OtherType = otherTypeCode, Comments = "expectedComment"
                }
            };

            // act
            // assert
            Func <Task> act = () => _classUnderTest.Execute(workOrderCompleteRequest);

            (await act.Should().ThrowAsync <NotSupportedException>())
            .Which.Message.Should().Be(Resources.UnsupportedWorkOrderUpdate);
        }
Esempio n. 6
0
        public async Task ContractManagerUpdatesWorkOrderStatusNoAccess()
        {
            // arrange
            const Generated.JobStatusUpdateTypeCode NoAccess = Generated.JobStatusUpdateTypeCode.DeniedAccess_70;
            WorkStatusCode expectedNewStatus = WorkStatusCode.NoAccess;

            _currentUserServiceMock.SetSecurityGroup(UserGroups.ContractManager, true);
            var expectedWorkOrder        = CreateWorkOrder();
            var workOrderCompleteRequest = CreateRequest(expectedWorkOrder.Id);

            workOrderCompleteRequest.JobStatusUpdates = new List <Generated.JobStatusUpdates>
            {
                new Generated.JobStatusUpdates
                {
                    TypeCode = NoAccess, Comments = "expectedComment"
                }
            };

            // act
            await _classUnderTest.Execute(workOrderCompleteRequest);

            // assert
            _repairsGatewayMock.Verify(rgm => rgm.UpdateWorkOrderStatus(expectedWorkOrder.Id, expectedNewStatus));
        }