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 GetInvoices_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { _invoiceService = InvoiceServiceFactory.Create( TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public), MockRepository.GenerateStub <IInvoiceRepository>(), MockRepository.GenerateStub <IListItemRepository>(), MockRepository.GenerateStub <ICustomerRepository>(), MockRepository.GenerateStub <IBankDetailsRepository>(), MockRepository.GenerateStub <ITaxCodeRepository>(), MockRepository.GenerateStub <ICurrencyRepository>()); GetInvoices(); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
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_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)); }