コード例 #1
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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");
        }
コード例 #2
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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));
        }
コード例 #3
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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));
        }
コード例 #4
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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));
        }
コード例 #5
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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);
        }
コード例 #6
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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));
        }
コード例 #7
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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));
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
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));
        }
コード例 #11
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));
        }
コード例 #12
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));
        }
コード例 #13
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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);
        }
コード例 #14
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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);
        }
コード例 #15
0
ファイル: JobItemTests.cs プロジェクト: mazj/JobSystem
        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);
        }
コード例 #16
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);
        }
コード例 #17
0
        public void Create_DeliveryWith0ItemsAndJobItemWithQuoteItem_DeliveryItemCreated()
        {
            var id         = Guid.NewGuid();
            var deliveryId = Guid.NewGuid();
            var jobItemId  = _jobItemToUpdateId;
            var notes      = "some notes";

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

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

            jobItemRepositoryMock.Stub(x => x.GetById(_jobItemToUpdateId)).Return(_jobItemToUpdate);
            jobItemRepositoryMock.Expect(x => x.EmitItemHistory(
                                             _userContext.GetCurrentUser(), _jobItemToUpdateId, 0, 0, "Item added to delivery note DR2000", ListItemType.StatusDeliveryNoteProduced, ListItemType.WorkTypeAdministration));
            jobItemRepositoryMock.Expect(x => x.Update(_jobItemToUpdate)).IgnoreArguments();

            _jobItemService      = JobItemServiceFactory.Create(_userContext, jobItemRepositoryMock);
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                DeliveryRepositoryTestHelper.GetDeliveryRepository_StubsGetByIdForDeliveryWith0Items_ReturnsDelivery(deliveryId),
                deliveryRepositoryMock,
                jobItemRepositoryMock,
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetByType_ReturnsListItem(new ListItemType[] { ListItemType.StatusDeliveryNoteProduced }),
                MockRepository.GenerateStub <ICustomerRepository>());
            CreateDeliveryItem(id, deliveryId, jobItemId, notes);
            deliveryRepositoryMock.VerifyAllExpectations();
            jobItemRepositoryMock.VerifyAllExpectations();
            Assert.AreNotEqual(Guid.Empty, _savedDeliveryItem.Id);
            Assert.AreEqual(1, _savedDeliveryItem.ItemNo);
            Assert.IsNotNull(_savedDeliveryItem.Delivery);
            Assert.IsNotNull(_savedDeliveryItem.JobItem);
            Assert.IsNotNull(_savedDeliveryItem.QuoteItem);
            Assert.AreEqual(ListItemType.StatusDeliveryNoteProduced, _jobItemToUpdate.Status.Type);
        }