Exemplo n.º 1
0
        public void Create_ValidDetailsSuppliedConsignmentHas1Items_SuccessfullyCreated()
        {
            var id            = Guid.NewGuid();
            var consignmentId = Guid.NewGuid();
            var instructions  = "Consignment instructions";

            var consignmentItemRepositoryMock = MockRepository.GenerateMock <IConsignmentItemRepository>();

            consignmentItemRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments();
            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(_jobItemToUpdate.Id)).Return(_jobItemToUpdate);
            jobItemRepositoryMock.Expect(x => x.EmitItemHistory(
                                             _userContext.GetCurrentUser(), _jobItemToUpdate.Id, 0, 0, "Item consigned on CR2000", ListItemType.StatusConsigned, ListItemType.WorkTypeAdministration));
            jobItemRepositoryMock.Expect(x => x.Update(_jobItemToUpdate)).IgnoreArguments();

            _consignmentItemService = ConsignmentItemServiceFactory.Create(consignmentItemRepositoryMock, jobItemRepositoryMock, consignmentId, _userContext, 1);
            _jobItemService         = _jobItemService = JobItemServiceFactory.CreateToReturnJobItem(jobItemRepositoryMock, _userContext);
            CreateConsignmentItem(id, _jobItemToUpdate.Id, consignmentId, instructions);
            consignmentItemRepositoryMock.VerifyAllExpectations();
            jobItemRepositoryMock.VerifyAllExpectations();
            Assert.AreNotEqual(Guid.Empty, _savedConsigmentItem.Id);
            Assert.AreEqual(2, _savedConsigmentItem.ItemNo);
            Assert.AreEqual(ListItemType.StatusConsigned, _jobItemToUpdate.Status.Type);
        }
Exemplo n.º 2
0
        private static IListItemRepository GetListItemRepositoryForInvoicedListItem(Guid workStatusId, Guid workTypeId)
        {
            var listItemRepositoryStub = MockRepository.GenerateStub <IListItemRepository>();

            listItemRepositoryStub.Stub(x => x.GetById(workStatusId)).Return(
                new ListItem
            {
                Id       = workTypeId,
                Type     = ListItemType.StatusInvoiced,
                Name     = "Invoiced",
                Category = new ListItemCategory
                {
                    Id   = Guid.NewGuid(),
                    Name = "Status",
                    Type = ListItemCategoryType.JobItemStatus
                }
            });
            listItemRepositoryStub.Stub(x => x.GetById(workTypeId)).Return(
                new ListItem
            {
                Id       = workTypeId,
                Type     = ListItemType.WorkTypeAdministration,
                Name     = "Administration",
                Category = new ListItemCategory
                {
                    Id   = Guid.NewGuid(),
                    Name = "Work Type",
                    Type = ListItemCategoryType.JobItemWorkType
                }
            });
            listItemRepositoryStub.Stub(x => x.GetById(workTypeId)).Return(JobItemServiceFactory.GetAddWorkItemWorkType(workTypeId));
            return(listItemRepositoryStub);
        }
Exemplo n.º 3
0
        public void CreateJobItem_InvalidFieldId_ArgumentExceptionThrown()
        {
            var jobId           = Guid.NewGuid();
            var jobItemId       = Guid.NewGuid();
            var instrumentId    = Guid.NewGuid();
            var initialStatusId = Guid.NewGuid();
            var fieldId         = Guid.Empty;

            _jobItemService = JobItemServiceFactory.Create(jobId, instrumentId, initialStatusId, fieldId, 0);
            CreateJobItem(jobId, jobItemId, instrumentId, "SER12345", "AS123", initialStatusId, fieldId, 12, "job item instructions", "job item accessories", false, "job item returned", "job item comments");
        }
Exemplo n.º 4
0
        public void CreateJobItem_CommentsGreaterThan255Characters_DomainValidationExceptionThrown()
        {
            var jobId           = Guid.NewGuid();
            var jobItemId       = Guid.NewGuid();
            var instrumentId    = Guid.NewGuid();
            var initialStatusId = Guid.NewGuid();
            var fieldId         = Guid.NewGuid();

            _jobItemService = JobItemServiceFactory.Create(jobId, instrumentId, initialStatusId, fieldId, 0);
            CreateJobItem(jobId, jobItemId, instrumentId, "SER123", "AS123", initialStatusId, fieldId, 12, "job item instructions", "job item accessories", false, "job item accessories", new string('a', 256));
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.CommentsTooLarge));
        }
Exemplo n.º 5
0
        public void CreateJobItem_SerialNoNotSupplied_DomainValidationExceptionThrown()
        {
            var jobId           = Guid.NewGuid();
            var jobItemId       = Guid.NewGuid();
            var instrumentId    = Guid.NewGuid();
            var initialStatusId = Guid.NewGuid();
            var fieldId         = Guid.NewGuid();

            _jobItemService = JobItemServiceFactory.Create(jobId, instrumentId, initialStatusId, fieldId, 0);
            CreateJobItem(jobId, jobItemId, instrumentId, String.Empty, "AS123", initialStatusId, fieldId, 12, "job item instructions", "job item accessories", false, "job item returned", "job item comments");
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.SerialNoRequired));
        }
Exemplo n.º 6
0
        public void CreateJobItem_InvalidCalPeriod_DomainValidationExceptionThrown()
        {
            var jobId           = Guid.NewGuid();
            var jobItemId       = Guid.NewGuid();
            var instrumentId    = Guid.NewGuid();
            var initialStatusId = Guid.NewGuid();
            var fieldId         = Guid.NewGuid();

            _jobItemService = JobItemServiceFactory.Create(jobId, instrumentId, initialStatusId, fieldId, 0);
            CreateJobItem(jobId, jobItemId, instrumentId, "SER12345", "AS123", initialStatusId, fieldId, 0, "job item instructions", "job item accessories", false, "job item returned", "job item comments");
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.InvalidCalPeriod));
        }
Exemplo n.º 7
0
        public void EditInformation_InvalidJobId_ArgumentExceptionThrown()
        {
            var id           = Guid.NewGuid();
            var serialNo     = "123456";
            var instructions = "edited instructions";
            var accessories  = "edited accessories";
            var comments     = "edited comments";

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(id)).Return(null);
            _jobItemService = JobItemServiceFactory.Create(_userContext, jobItemRepositoryMock);
            EditInformation(id, serialNo, instructions, accessories, comments);
        }
Exemplo n.º 8
0
        public void EditInformation_SerialNoTooLarge_DomainValidationExceptionThrown()
        {
            var serialNo     = new string('a', 51);
            var instructions = "some instructions";
            var accessories  = "some accessories";
            var comments     = "some comments";

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(_jobItemForEditInformationId)).Return(_jobItemForEditInformation);
            _jobItemService = JobItemServiceFactory.Create(_userContext, jobItemRepositoryMock);
            EditInformation(_jobItemForEditInformationId, serialNo, instructions, accessories, comments);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.SerialNoTooLarge));
        }
Exemplo n.º 9
0
        public void Create_InvalidJobItemIdSupplied_ArgumentExceptionThrown()
        {
            var id            = Guid.NewGuid();
            var consignmentId = Guid.NewGuid();
            var instructions  = "Consignment instructions";

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(Guid.NewGuid())).Return(null);

            _consignmentItemService = ConsignmentItemServiceFactory.Create(MockRepository.GenerateStub <IConsignmentItemRepository>(), jobItemRepositoryMock, consignmentId, _userContext);
            _jobItemService         = _jobItemService = JobItemServiceFactory.CreateToReturnJobItem(jobItemRepositoryMock, _userContext);
            CreateConsignmentItem(id, _jobItemToUpdate.Id, consignmentId, instructions);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
        public void Create_InstructionsGreaterThan10000Characters_DomainValidationExceptionThrown()
        {
            var id            = Guid.NewGuid();
            var consignmentId = Guid.NewGuid();
            var instructions  = new string('a', 10001);

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(_jobItemToUpdate.Id)).Return(_jobItemToUpdate);

            _consignmentItemService = ConsignmentItemServiceFactory.Create(MockRepository.GenerateStub <IConsignmentItemRepository>(), jobItemRepositoryMock, consignmentId, _userContext);
            _jobItemService         = _jobItemService = JobItemServiceFactory.CreateToReturnJobItem(jobItemRepositoryMock, _userContext);
            CreateConsignmentItem(id, _jobItemToUpdate.Id, consignmentId, instructions);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InstructionsTooLarge));
        }
Exemplo n.º 13
0
        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));
        }
Exemplo n.º 14
0
        public void Create_NoIdSupplied_ArgumentExceptionThrown()
        {
            var id            = Guid.Empty;
            var consignmentId = Guid.NewGuid();
            var instructions  = "Consignment instructions";

            _jobItemToUpdate.Job.IsPending = true;
            var jobItemRepositoryStub = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryStub.Stub(x => x.GetById(_jobItemToUpdate.Id)).Return(_jobItemToUpdate);

            _consignmentItemService = ConsignmentItemServiceFactory.Create(MockRepository.GenerateStub <IConsignmentItemRepository>(), jobItemRepositoryStub, consignmentId, _userContext);
            _jobItemService         = _jobItemService = JobItemServiceFactory.CreateToReturnJobItem(jobItemRepositoryStub, _userContext);
            CreateConsignmentItem(id, _jobItemToUpdate.Id, consignmentId, instructions);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.PendingJob));
        }
Exemplo n.º 15
0
        public void EditInformation_InsufficientSecurityClearance_DomainValidationExceptionThrown()
        {
            var serialNo     = "123456";
            var instructions = "some instructions";
            var accessories  = "some accessories";
            var comments     = "some comments";

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(_jobItemForEditInformationId)).Return(_jobItemForEditInformation);
            _jobItemService = JobItemServiceFactory.Create(
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Member),
                jobItemRepositoryMock);
            EditInformation(_jobItemForEditInformationId, serialNo, instructions, accessories, comments);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.JobItems.Messages.InsufficientSecurityClearance));
        }
Exemplo n.º 16
0
        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));
        }
Exemplo n.º 17
0
        public void Create_UserHasInsufficientSecurityClearance_ArgumentExceptionThrown()
        {
            var id            = Guid.NewGuid();
            var consignmentId = Guid.NewGuid();
            var instructions  = "Consignment instructions";

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(Guid.NewGuid())).Return(null);

            _consignmentItemService = ConsignmentItemServiceFactory.Create(
                MockRepository.GenerateStub <IConsignmentItemRepository>(), jobItemRepositoryMock, consignmentId,
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public));
            _jobItemService = _jobItemService = JobItemServiceFactory.CreateToReturnJobItem(jobItemRepositoryMock,
                                                                                            TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public));
            CreateConsignmentItem(id, _jobItemToUpdate.Id, consignmentId, instructions);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance));
        }
Exemplo n.º 18
0
        public void Create_InvalidDeliveryId_ArgumentExceptionThrown()
        {
            var id         = Guid.NewGuid();
            var deliveryId = Guid.NewGuid();
            var jobItemId  = _jobItemToUpdateId;
            var notes      = "some notes";

            _jobItemService      = JobItemServiceFactory.Create(_userContext, MockRepository.GenerateStub <IJobItemRepository>());
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                DeliveryRepositoryTestHelper.GetDeliveryRepository_StubsGetById_ReturnsNull(deliveryId),
                MockRepository.GenerateStub <IDeliveryItemRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetByType_ReturnsListItem(new ListItemType[] { ListItemType.StatusDeliveryNoteProduced }),
                MockRepository.GenerateStub <ICustomerRepository>());
            CreateDeliveryItem(id, deliveryId, jobItemId, notes);
        }
Exemplo n.º 19
0
        public void Edit_InvalidDeliveryItemId_ThrowsArgumentException()
        {
            var notes = "some notes";

            var deliveryItemRepositoryStub = MockRepository.GenerateMock <IDeliveryItemRepository>();

            deliveryItemRepositoryStub.Stub(x => x.GetById(_deliveryItemForEditId)).Return(null);
            _jobItemService      = JobItemServiceFactory.Create(_userContext, MockRepository.GenerateStub <IJobItemRepository>());
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <IDeliveryRepository>(),
                deliveryItemRepositoryStub,
                MockRepository.GenerateStub <IJobItemRepository>(),
                MockRepository.GenerateStub <IQuoteItemRepository>(),
                MockRepository.GenerateStub <IListItemRepository>(),
                MockRepository.GenerateStub <ICustomerRepository>());
            Edit(_deliveryItemForEditId, notes);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        public void Edit_NotesGreaterThan255Characters_ThrowsDomainValidationException()
        {
            var notes = new string('a', 256);

            var deliveryItemRepositoryStub = MockRepository.GenerateMock <IDeliveryItemRepository>();

            deliveryItemRepositoryStub.Stub(x => x.GetById(_deliveryItemForEditId)).Return(_deliveryItemForEdit);
            _jobItemService      = JobItemServiceFactory.Create(_userContext, MockRepository.GenerateStub <IJobItemRepository>());
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <IDeliveryRepository>(),
                deliveryItemRepositoryStub,
                MockRepository.GenerateStub <IJobItemRepository>(),
                MockRepository.GenerateStub <IQuoteItemRepository>(),
                MockRepository.GenerateStub <IListItemRepository>(),
                MockRepository.GenerateStub <ICustomerRepository>());
            Edit(_deliveryItemForEditId, notes);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(DeliveryItemMessages.InvalidNotes));
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        public void Create_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown()
        {
            var id         = Guid.NewGuid();
            var deliveryId = Guid.NewGuid();
            var jobItemId  = _jobItemToUpdateId;
            var notes      = "some notes";

            _jobItemService      = JobItemServiceFactory.Create(_userContext, MockRepository.GenerateStub <IJobItemRepository>());
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public),
                DeliveryRepositoryTestHelper.GetDeliveryRepository_StubsGetByIdForDeliveryWith1Item_ReturnsDelivery(deliveryId),
                MockRepository.GenerateStub <IDeliveryItemRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetByType_ReturnsListItem(new ListItemType[] { ListItemType.StatusDeliveryNoteProduced }),
                MockRepository.GenerateStub <ICustomerRepository>());
            CreateDeliveryItem(id, deliveryId, jobItemId, notes);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(DeliveryItemMessages.InsufficientSecurityClearance));
        }
Exemplo n.º 24
0
        public void Create_NotesGreaterThan255Characters_DomainValidationExceptionThrown()
        {
            var id         = Guid.NewGuid();
            var deliveryId = Guid.NewGuid();
            var jobItemId  = _jobItemToUpdateId;
            var notes      = new string('a', 256);

            _jobItemService      = JobItemServiceFactory.Create(_userContext, MockRepository.GenerateStub <IJobItemRepository>());
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                DeliveryRepositoryTestHelper.GetDeliveryRepository_StubsGetByIdForDeliveryWith1Item_ReturnsDelivery(deliveryId),
                MockRepository.GenerateStub <IDeliveryItemRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetByType_ReturnsListItem(new ListItemType[] { ListItemType.StatusDeliveryNoteProduced }),
                MockRepository.GenerateStub <ICustomerRepository>());
            CreateDeliveryItem(id, deliveryId, jobItemId, notes);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(DeliveryItemMessages.InvalidNotes));
        }
Exemplo n.º 25
0
        private static IListItemRepository GetListItemRepositoryForInvalidStatusCategory(Guid workStatusId, Guid workTypeId)
        {
            var listItemRepositoryStub = MockRepository.GenerateStub <IListItemRepository>();

            listItemRepositoryStub.Stub(x => x.GetById(workStatusId)).Return(
                new ListItem
            {
                Id       = Guid.NewGuid(),
                Type     = ListItemType.InitialStatusHouseCalibration,
                Name     = "House Calibration",
                Category = new ListItemCategory
                {
                    Id   = Guid.NewGuid(),
                    Name = "Initial Status",
                    Type = ListItemCategoryType.JobItemInitialStatus
                }
            });
            listItemRepositoryStub.Stub(x => x.GetById(workTypeId)).Return(JobItemServiceFactory.GetAddWorkItemWorkType(workTypeId));
            return(listItemRepositoryStub);
        }
Exemplo n.º 26
0
        private static IListItemRepository GetListItemRepositoryForInvalidWorkTypeCategory(Guid workStatusId, Guid workTypeId)
        {
            var listItemRepositoryStub = MockRepository.GenerateStub <IListItemRepository>();

            listItemRepositoryStub.Stub(x => x.GetById(workStatusId)).Return(JobItemServiceFactory.GetAddWorkItemWorkStatus(workStatusId));
            listItemRepositoryStub.Stub(x => x.GetById(workTypeId)).Return(
                new ListItem
            {
                Id       = Guid.NewGuid(),
                Type     = ListItemType.WorkStatusRepaired,
                Name     = "Repaired",
                Category = new ListItemCategory
                {
                    Id   = Guid.NewGuid(),
                    Name = "Status",
                    Type = ListItemCategoryType.JobItemWorkStatus
                }
            });
            return(listItemRepositoryStub);
        }
Exemplo n.º 27
0
        public void CreateJobItem_ValidJobItemDetailsWithFirstItem_JobItemCreatedSuccessfullyWithItemNoAs2()
        {
            var jobId           = Guid.NewGuid();
            var jobItemId       = Guid.NewGuid();
            var instrumentId    = Guid.NewGuid();
            var initialStatusId = Guid.NewGuid();
            var fieldId         = Guid.NewGuid();

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments();
            _jobItemService = JobItemServiceFactory.Create(
                jobItemRepositoryMock, jobId, instrumentId, initialStatusId, fieldId, 1, TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Member));
            CreateJobItem(jobId, jobItemId, instrumentId, "SER12345", "AS123", initialStatusId, fieldId, 12, "job item instructions", "job item accessories", false, "job item returned", "job item comments");
            jobItemRepositoryMock.VerifyAllExpectations();
            Assert.That(_savedJobItem.Id != Guid.Empty);
            Assert.AreEqual(2, _savedJobItem.ItemNo);
            Assert.AreEqual(_dateCreated, _savedJobItem.Created);
            Assert.AreEqual("*****@*****.**", _savedJobItem.CreatedUser.EmailAddress);
            Assert.AreEqual("Booked In", _savedJobItem.Status.Name);
        }
Exemplo n.º 28
0
        public void EditInformation_ValidInformation_JobItemEdited()
        {
            var serialNo     = "123456";
            var instructions = "edited instructions";
            var accessories  = "edited accessories";
            var comments     = "edited comments";

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(_jobItemForEditInformationId)).Return(_jobItemForEditInformation);
            jobItemRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments();
            _jobItemService = JobItemServiceFactory.Create(_userContext, jobItemRepositoryMock);

            EditInformation(_jobItemForEditInformationId, serialNo, instructions, accessories, comments);
            jobItemRepositoryMock.VerifyAllExpectations();
            Assert.AreEqual(_jobItemForEditInformationId, _jobItemForEditInformation.Id);
            Assert.AreEqual(serialNo, _jobItemForEditInformation.SerialNo);
            Assert.AreEqual(instructions, _jobItemForEditInformation.Instructions);
            Assert.AreEqual(accessories, _jobItemForEditInformation.Accessories);
            Assert.AreEqual(comments, _jobItemForEditInformation.Comments);
        }
Exemplo n.º 29
0
        public void Edit_ValidItemDetails_ItemEdited()
        {
            var notes = "some notes";

            var deliveryItemRepositoryMock = MockRepository.GenerateMock <IDeliveryItemRepository>();

            deliveryItemRepositoryMock.Stub(x => x.GetById(_deliveryItemForEditId)).Return(_deliveryItemForEdit);
            deliveryItemRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments();
            _jobItemService      = JobItemServiceFactory.Create(_userContext, MockRepository.GenerateStub <IJobItemRepository>());
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <IDeliveryRepository>(),
                deliveryItemRepositoryMock,
                MockRepository.GenerateStub <IJobItemRepository>(),
                MockRepository.GenerateStub <IQuoteItemRepository>(),
                MockRepository.GenerateStub <IListItemRepository>(),
                MockRepository.GenerateStub <ICustomerRepository>());
            Edit(_deliveryItemForEditId, notes);
            deliveryItemRepositoryMock.VerifyAllExpectations();
            Assert.AreEqual(_deliveryItemForEditId, _deliveryItemForEdit.Id);
            Assert.AreEqual(notes, _deliveryItemForEdit.Notes);
        }
Exemplo n.º 30
0
        public void EditInformation_UserIsAdmin_JobItemEdited()
        {
            var serialNo     = "123456";
            var instructions = "edited instructions";
            var accessories  = "edited accessories";
            var comments     = "edited comments";

            var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>();

            jobItemRepositoryMock.Stub(x => x.GetById(_jobItemForEditInformationId)).Return(_jobItemForEditInformation);
            jobItemRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments();
            _jobItemService = JobItemServiceFactory.Create(
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Admin | UserRole.Member),
                jobItemRepositoryMock);

            EditInformation(_jobItemForEditInformationId, serialNo, instructions, accessories, comments);
            jobItemRepositoryMock.VerifyAllExpectations();
            Assert.AreEqual(_jobItemForEditInformationId, _jobItemForEditInformation.Id);
            Assert.AreEqual(instructions, _jobItemForEditInformation.Instructions);
            Assert.AreEqual(accessories, _jobItemForEditInformation.Accessories);
            Assert.AreEqual(comments, _jobItemForEditInformation.Comments);
        }