public void AddWorkItem_InvalidWorkTypeId_ArgumentExceptionThrown() { var workStatusId = Guid.NewGuid(); var workTypeId = Guid.Empty; var workTime = 25; var overTime = 10; var report = "Instrument calibrated OK"; var jobItemRepositoryStub = MockRepository.GenerateStub <IJobItemRepository>(); jobItemRepositoryStub.Stub(x => x.GetById(_jobItemToUpdateId)).Return(_jobItemToUpdate); _jobItemService = JobItemServiceFactory.CreateForAddWorkItem(jobItemRepositoryStub, workStatusId, workTypeId, _userContext); AddWorkItem(_jobItemToUpdateId, workTime, overTime, report, workStatusId, workTypeId); }
public void AddWorkItem_JobNotApproved_DomainValidationExceptionThrown() { var workStatusId = Guid.NewGuid(); var workTypeId = Guid.NewGuid(); var workTime = 25; var overTime = 10; var report = "Instrument calibrated OK"; var jobItemRepositoryStub = MockRepository.GenerateStub <IJobItemRepository>(); jobItemRepositoryStub.Stub(x => x.GetById(_jobItemToUpdateJobNotApprovedId)).Return(_jobItemToUpdateJobNotApproved); _jobItemService = JobItemServiceFactory.CreateForAddWorkItem(jobItemRepositoryStub, workStatusId, workTypeId, _userContext); AddWorkItem(_jobItemToUpdateJobNotApprovedId, workTime, overTime, report, workStatusId, workTypeId); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.JobNotApproved)); }
public void AddWorkItem_InvalidReportSupplied_DomainValidationExceptionThrown() { var workStatusId = Guid.NewGuid(); var workTypeId = Guid.NewGuid(); var workTime = 25; var overTime = 10; var report = new string('a', 256); var jobItemRepositoryStub = MockRepository.GenerateStub <IJobItemRepository>(); jobItemRepositoryStub.Stub(x => x.GetById(_jobItemToUpdateId)).Return(_jobItemToUpdate); _jobItemService = JobItemServiceFactory.CreateForAddWorkItem(jobItemRepositoryStub, workStatusId, workTypeId, _userContext); AddWorkItem(_jobItemToUpdateId, workTime, overTime, report, workStatusId, workTypeId); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.ItemHistoryReportTooLarge)); }
public void AddWorkItem_CurrentUserHasInsufficientSecurity_DomainValidationExceptionThrown() { var workStatusId = Guid.NewGuid(); var workTypeId = Guid.NewGuid(); var workTime = 25; var overTime = 10; var report = "Instrument calibrated OK"; var jobItemRepositoryStub = MockRepository.GenerateStub <IJobItemRepository>(); jobItemRepositoryStub.Stub(x => x.GetById(_jobItemToUpdateId)).Return(_jobItemToUpdate); _jobItemService = JobItemServiceFactory.CreateForAddWorkItem( jobItemRepositoryStub, workStatusId, workTypeId, TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public)); AddWorkItem(_jobItemToUpdateId, workTime, overTime, report, workStatusId, workTypeId); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.InsufficientSecurityClearance)); }
public void AddWorkItem_ItemHasInvoicedStatus_ItemPersistsWithoutError() { var workStatusId = Guid.NewGuid(); var workTypeId = Guid.NewGuid(); var workTime = 25; var overTime = 10; var report = "Item invoiced"; var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>(); jobItemRepositoryMock.Stub(x => x.GetById(_jobItemToUpdateId)).Return(_jobItemToUpdate); jobItemRepositoryMock.Expect(x => x.EmitItemHistory( _userContext.GetCurrentUser(), _jobItemToUpdateId, workTime, overTime, report, ListItemType.StatusInvoiced, ListItemType.WorkTypeAdministration)); jobItemRepositoryMock.Expect(x => x.Update(_jobItemToUpdate)); _jobItemService = JobItemServiceFactory.CreateForAddWorkItem(jobItemRepositoryMock, GetListItemRepositoryForInvoicedListItem(workStatusId, workTypeId), _userContext); AddWorkItem(_jobItemToUpdateId, workTime, overTime, report, workStatusId, workTypeId); jobItemRepositoryMock.VerifyAllExpectations(); Assert.AreEqual(ListItemType.StatusInvoiced, _savedJobItem.Status.Type); }
public void AddWorkItem_ValidWorkItemDetails_WorkItemAdded() { var workStatusId = Guid.NewGuid(); var workTypeId = Guid.NewGuid(); var workTime = 25; var overTime = 10; var report = "Instrument calibrated OK"; var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>(); jobItemRepositoryMock.Stub(x => x.GetById(_jobItemToUpdateId)).Return(_jobItemToUpdate); jobItemRepositoryMock.Expect(x => x.EmitItemHistory( _userContext.GetCurrentUser(), _jobItemToUpdateId, workTime, overTime, report, ListItemType.WorkStatusCalibrated, ListItemType.WorkTypeCalibration)); jobItemRepositoryMock.Expect(x => x.Update(_jobItemToUpdate)); _jobItemService = JobItemServiceFactory.CreateForAddWorkItem(jobItemRepositoryMock, workStatusId, workTypeId, _userContext); AddWorkItem(_jobItemToUpdateId, workTime, overTime, report, workStatusId, workTypeId); jobItemRepositoryMock.VerifyAllExpectations(); Assert.AreEqual(ListItemType.WorkStatusCalibrated, _savedJobItem.Status.Type); }