public void Create_ValidInvoiceDetails_InvoiceCreated() { var id = Guid.NewGuid(); var currencyId = Guid.NewGuid(); var customerId = Guid.NewGuid(); var orderNo = "ORDER123454"; var bankDetailsId = Guid.NewGuid(); var paymentTermId = Guid.NewGuid(); var taxCodeId = Guid.NewGuid(); var invoiceRepositoryMock = MockRepository.GenerateMock <IInvoiceRepository>(); invoiceRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); _invoiceService = InvoiceServiceFactory.Create( _userContext, invoiceRepositoryMock, ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsPaymentTerm(paymentTermId), CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId), BankDetailsRepositoryTestHelper.GetBankDetailsRepository_StubsGetById_ReturnsBankDetails(bankDetailsId), TaxCodeRepositoryTestHelper.GetTaxCodeRepository_StubsGetById_ReturnsTaxCode(taxCodeId), CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId)); Create(id, currencyId, customerId, bankDetailsId, paymentTermId, taxCodeId, orderNo); invoiceRepositoryMock.VerifyAllExpectations(); Assert.AreNotEqual(Guid.Empty, _savedInvoice.Id); Assert.That(_savedInvoice.InvoiceNumber.StartsWith("IR")); Assert.AreEqual(_dateCreated, _savedInvoice.DateCreated); Assert.AreEqual(orderNo, _savedInvoice.OrderNo); Assert.IsNotNull(_savedInvoice.Currency); Assert.IsNotNull(_savedInvoice.Customer); Assert.IsNotNull(_savedInvoice.BankDetails); Assert.IsNotNull(_savedInvoice.PaymentTerm); Assert.IsNotNull(_savedInvoice.TaxCode); }
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); }
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); }
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)); }
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)); }
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); }
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)); }
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)); }
public void Create_InvalidTaxCodeId_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var currencyId = Guid.NewGuid(); var orderNo = "ORDER123454"; var customerId = Guid.NewGuid(); var bankDetailsId = Guid.NewGuid(); var paymentTermId = Guid.NewGuid(); var taxCodeId = Guid.NewGuid(); _invoiceService = InvoiceServiceFactory.Create( _userContext, MockRepository.GenerateStub <IInvoiceRepository>(), ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsPaymentTerm(paymentTermId), CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId), BankDetailsRepositoryTestHelper.GetBankDetailsRepository_StubsGetById_ReturnsBankDetails(bankDetailsId), TaxCodeRepositoryTestHelper.GetTaxCodeRepository_StubsGetById_ReturnsNull(taxCodeId), CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId)); Create(id, currencyId, customerId, bankDetailsId, paymentTermId, taxCodeId, orderNo); }
public void Create_UserHasInsufficientSecurityClearance_ArgumentExceptionThrown() { var id = Guid.NewGuid(); var currencyId = Guid.NewGuid(); var orderNo = "ORDER123454"; var customerId = Guid.NewGuid(); var bankDetailsId = Guid.NewGuid(); var paymentTermId = Guid.NewGuid(); var taxCodeId = Guid.NewGuid(); _invoiceService = InvoiceServiceFactory.Create( TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Member), MockRepository.GenerateStub <IInvoiceRepository>(), ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsPaymentTerm(paymentTermId), CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId), BankDetailsRepositoryTestHelper.GetBankDetailsRepository_StubsGetById_ReturnsBankDetails(bankDetailsId), TaxCodeRepositoryTestHelper.GetTaxCodeRepository_StubsGetById_ReturnsTaxCode(taxCodeId), CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId)); Create(id, currencyId, customerId, bankDetailsId, paymentTermId, taxCodeId, orderNo); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
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); }
public void Create_InvalidOrderNo_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var currencyId = Guid.NewGuid(); var customerId = Guid.NewGuid(); var orderNo = new string('a', 51); var bankDetailsId = Guid.NewGuid(); var paymentTermId = Guid.NewGuid(); var taxCodeId = Guid.NewGuid(); var invoiceRepositoryMock = MockRepository.GenerateMock <IInvoiceRepository>(); invoiceRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); _invoiceService = InvoiceServiceFactory.Create( _userContext, invoiceRepositoryMock, ListItemRepositoryTestHelper.GetListItemRepository_StubsGetById_ReturnsPaymentTerm(paymentTermId), CustomerRepositoryTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId), BankDetailsRepositoryTestHelper.GetBankDetailsRepository_StubsGetById_ReturnsBankDetails(bankDetailsId), TaxCodeRepositoryTestHelper.GetTaxCodeRepository_StubsGetById_ReturnsTaxCode(taxCodeId), CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId)); Create(id, currencyId, customerId, bankDetailsId, paymentTermId, taxCodeId, orderNo); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.OrderNoTooLarge)); }