예제 #1
0
        public void CreatePending_QuoteItemPrepared_DomainValidationExceptionThrown()
        {
            var id        = Guid.NewGuid();
            var jobItemId = _jobItemForCreatePendingId;

            _quoteItemForCreatePending.Status =
                new ListItem
            {
                Id       = Guid.NewGuid(),
                Name     = "Quote Prepared",
                Type     = ListItemType.StatusQuotedPrepared,
                Category = new ListItemCategory {
                    Id = Guid.NewGuid(), Name = "Job Item Status", Type = ListItemCategoryType.JobItemStatus
                }
            };

            _invoiceItemService = InvoiceItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <ICompanyDetailsRepository>(),
                MockRepository.GenerateStub <IInvoiceRepository>(),
                InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsFalse(jobItemId),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending),
                MockRepository.GenerateStub <IListItemRepository>());
            CreatePending(id, jobItemId);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.QuoteStatusInvalid));
        }
예제 #2
0
        public void CreatePending_JobItemWithQuoteItem_PendingItemCreatedSuccessfully()
        {
            var id         = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var jobItemId  = Guid.NewGuid();
            var notes      = "some notes";

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

            deliveryItemRepositoryMock.Expect(x => x.CreatePending(null)).IgnoreArguments();
            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <IDeliveryRepository>(),
                deliveryItemRepositoryMock,
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                MockRepository.GenerateStub <IListItemRepository>(),
                CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId));
            CreatePending(id, customerId, jobItemId, notes);
            deliveryItemRepositoryMock.VerifyAllExpectations();
            Assert.AreNotEqual(Guid.Empty, _savedPendingItem.Id);
            Assert.IsNotNull(_savedPendingItem.JobItem);
            Assert.IsNotNull(_savedPendingItem.QuoteItem);
            Assert.IsNotNull(_savedPendingItem.Customer);
        }
예제 #3
0
        public void CreatePending_ApplyAllPrices_ItemCreatedWithAllPricesApplied()
        {
            var id        = Guid.NewGuid();
            var jobItemId = _jobItemForCreatePendingId;

            var invoiceItemRepositoryMock = MockRepository.GenerateMock <IInvoiceItemRepository>();

            invoiceItemRepositoryMock.Stub(x => x.JobItemHasPendingInvoiceItem(jobItemId)).Return(false);
            invoiceItemRepositoryMock.Expect(x => x.CreatePendingItem(null)).IgnoreArguments();
            _invoiceItemService = InvoiceItemServiceFactory.Create(
                _userContext,
                CompanyDetailsRepositoryTestHelper.GetCompanyDetailsRepository_StubsApplyAllPrices_ReturnsTrue(),
                MockRepository.GenerateStub <IInvoiceRepository>(),
                invoiceItemRepositoryMock,
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending),
                MockRepository.GenerateStub <IListItemRepository>());
            CreatePending(id, jobItemId);
            invoiceItemRepositoryMock.VerifyAllExpectations();
            Assert.AreNotEqual(Guid.Empty, _savedPendingItem.Id);
            Assert.IsNotNull(_savedPendingItem.JobItem);
            Assert.AreEqual(_quoteItemForCreatePending.JobItem.Instrument.ToString(), _savedPendingItem.Description);
            Assert.AreEqual(_quoteItemForCreatePending.Quote.OrderNumber, _savedPendingItem.OrderNo);
            Assert.AreEqual(_quoteItemForCreatePending.Calibration, _savedPendingItem.CalibrationPrice);
            Assert.AreEqual(_quoteItemForCreatePending.Labour, _savedPendingItem.RepairPrice);
            Assert.AreEqual(_quoteItemForCreatePending.Parts, _savedPendingItem.PartsPrice);
            Assert.AreEqual(_quoteItemForCreatePending.Carriage, _savedPendingItem.CarriagePrice);
            Assert.AreEqual(_quoteItemForCreatePending.Investigation, _savedPendingItem.InvestigationPrice);
        }
예제 #4
0
        public void Create_ValidCertificateDetails_CertificateCreated()
        {
            var id = Guid.NewGuid();
            var certificateTypeId = Guid.NewGuid();
            var categoryId        = Guid.NewGuid();
            var jobItemId         = Guid.NewGuid();
            var procedureList     = "001; 002";

            var certificateRepositoryMock = MockRepository.GenerateMock <ICertificateRepository>();

            certificateRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments();
            _certificateService = CertificateServiceFactory.Create(
                _userContext,
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsCertificateAndCategory(certificateTypeId, categoryId),
                certificateRepositoryMock,
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId));
            Create(id, certificateTypeId, categoryId, jobItemId, procedureList);
            certificateRepositoryMock.VerifyAllExpectations();
            Assert.AreNotEqual(Guid.Empty, _savedCertificate.Id);
            Assert.AreEqual("E2000", _savedCertificate.CertificateNumber);
            Assert.AreEqual(_dateCreated, _savedCertificate.DateCreated);
            Assert.AreEqual("*****@*****.**", _savedCertificate.CreatedBy.EmailAddress);
            Assert.IsNotNull(_savedCertificate.JobItem);
            Assert.IsNotNull(_savedCertificate.Type);
            Assert.IsNotNull(_savedCertificate.Category);
        }
예제 #5
0
        public void Create_NonCertificateListItemId_ArgumentExceptionThrown()
        {
            var id = Guid.NewGuid();
            var certificateTypeId = Guid.NewGuid();
            var categoryId        = Guid.NewGuid();
            var jobItemId         = Guid.NewGuid();
            var procedureList     = "001; 002";

            _certificateService = CertificateServiceFactory.Create(
                _userContext,
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsNonCertificateType(certificateTypeId),
                MockRepository.GenerateStub <ICertificateRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId));
            Create(id, certificateTypeId, categoryId, jobItemId, procedureList);
        }
예제 #6
0
        public void CreatePending_InvalidJobItemId_ArgumentExceptionThrown()
        {
            var id        = Guid.NewGuid();
            var jobItemId = Guid.NewGuid();

            _invoiceItemService = InvoiceItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <ICompanyDetailsRepository>(),
                MockRepository.GenerateStub <IInvoiceRepository>(),
                InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsFalse(jobItemId),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsNull(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending),
                MockRepository.GenerateStub <IListItemRepository>());
            CreatePending(id, jobItemId);
        }
예제 #7
0
        public void Create_UserHasInsufficientClearance_DomainValidationExceptionThrown()
        {
            var id = Guid.NewGuid();
            var certificateTypeId = Guid.NewGuid();
            var categoryId        = Guid.NewGuid();
            var jobItemId         = Guid.NewGuid();
            var procedureList     = "001; 002";

            _certificateService = CertificateServiceFactory.Create(
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public),
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsCertificateAndCategory(certificateTypeId, categoryId),
                MockRepository.GenerateStub <ICertificateRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId));
            Create(id, certificateTypeId, categoryId, jobItemId, procedureList);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance));
        }
예제 #8
0
        public void Create_ProcedureListGreaterThan255Characters_DomainValidationExceptionThrown()
        {
            var id = Guid.NewGuid();
            var certificateTypeId = Guid.NewGuid();
            var categoryId        = Guid.NewGuid();
            var jobItemId         = Guid.NewGuid();
            var procedureList     = new string('a', 256);

            _certificateService = CertificateServiceFactory.Create(
                _userContext,
                ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsCertificateAndCategory(certificateTypeId, categoryId),
                MockRepository.GenerateStub <ICertificateRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId));
            Create(id, certificateTypeId, categoryId, jobItemId, procedureList);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ProcedureListTooLarge));
        }
예제 #9
0
        public void CreatePending_JobItemAlreadyHasPendingItem_DomainValidationExceptionThrown()
        {
            var id        = Guid.NewGuid();
            var jobItemId = _jobItemForCreatePendingId;

            _invoiceItemService = InvoiceItemServiceFactory.Create(
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public),
                MockRepository.GenerateStub <ICompanyDetailsRepository>(),
                MockRepository.GenerateStub <IInvoiceRepository>(),
                InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsTrue(jobItemId),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending),
                MockRepository.GenerateStub <IListItemRepository>());
            CreatePending(id, jobItemId);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.JobItemHasPendingItem));
        }
예제 #10
0
        public void CreatePending_QuoteItemNotRaised_DomainValidationExceptionThrown()
        {
            var id        = Guid.NewGuid();
            var jobItemId = _jobItemForCreatePendingId;

            _invoiceItemService = InvoiceItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <ICompanyDetailsRepository>(),
                MockRepository.GenerateStub <IInvoiceRepository>(),
                InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsFalse(jobItemId),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsNull(jobItemId),
                MockRepository.GenerateStub <IListItemRepository>());
            CreatePending(id, jobItemId);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.QuoteItemNull));
        }
예제 #11
0
        public void CreatePending_InvalidCustomerId_ArgumentExceptionThrown()
        {
            var id         = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var jobItemId  = Guid.NewGuid();
            var notes      = "some notes";

            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <IDeliveryRepository>(),
                MockRepository.GenerateStub <IDeliveryItemRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                MockRepository.GenerateStub <IListItemRepository>(),
                CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsNull(customerId));
            CreatePending(id, customerId, jobItemId, notes);
        }
예제 #12
0
        public void CreatePending_UserHasInsufficientSecurityClearance_ArgumentExceptionThrown()
        {
            var id         = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var jobItemId  = Guid.NewGuid();
            var notes      = "some notes";

            _deliveryItemService = DeliveryItemServiceFactory.Create(
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public),
                MockRepository.GenerateStub <IDeliveryRepository>(),
                MockRepository.GenerateStub <IDeliveryItemRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                MockRepository.GenerateStub <IListItemRepository>(),
                CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId));
            CreatePending(id, customerId, jobItemId, notes);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(DeliveryItemMessages.InsufficientSecurityClearance));
        }
예제 #13
0
        public void CreatePending_NotesGreaterThan255Characters_ArgumentExceptionThrown()
        {
            var id         = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var jobItemId  = Guid.NewGuid();
            var notes      = new string('a', 256);

            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <IDeliveryRepository>(),
                MockRepository.GenerateStub <IDeliveryItemRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                MockRepository.GenerateStub <IListItemRepository>(),
                CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId));
            CreatePending(id, customerId, jobItemId, notes);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(DeliveryItemMessages.InvalidNotes));
        }
예제 #14
0
        public void CreatePending_JobIsPending_DomainValidationExceptionThrown()
        {
            var id         = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var jobItemId  = Guid.NewGuid();
            var notes      = "some notes";

            _deliveryItemService = DeliveryItemServiceFactory.Create(
                _userContext,
                MockRepository.GenerateStub <IDeliveryRepository>(),
                MockRepository.GenerateStub <IDeliveryItemRepository>(),
                JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItemOnPendingJob(jobItemId),
                QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId),
                MockRepository.GenerateStub <IListItemRepository>(),
                CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsNull(customerId));
            CreatePending(id, customerId, jobItemId, notes);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(DeliveryItemMessages.JobPending));
        }
예제 #15
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);
        }
예제 #16
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));
        }
예제 #17
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));
        }