public void Create_Address4GreaterThan50Characters_DomainValidationExceptionThrown() { var customerRepositoryStub = MockRepository.GenerateMock<ICustomerRepository>(); customerRepositoryStub.Stub(x => x.GetByName("Gael Ltd")).Return(null); _customerService = CustomerServiceFactory.Create(customerRepositoryStub); var tradingAddressDetails = GetAddressDetails("Trading"); tradingAddressDetails.Line4 = GreaterThan256Characters; CreateCustomer( Guid.NewGuid(), "Gael Ltd", tradingAddressDetails, GetContactInfo("Trading"), "Gael Ltd Invoice Address", GetAddressDetails("Invoicing"), GetContactInfo("Invoicing"), "Gael Ltd Delivery Address", GetAddressDetails("Delivery"), GetContactInfo("Delivery")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Customers.Messages.AddressLineTooLarge)); }
public void Edit_InvoiceContact1GreaterThan50Characters_DomainValidationExceptionThrown() { var customer = GetCustomerToEdit(); var customerRepositoryStub = MockRepository.GenerateMock<ICustomerRepository>(); customerRepositoryStub.Stub(x => x.GetById(customer.Id)).Return(customer); _customerService = CustomerServiceFactory.Create(customerRepositoryStub); var invoiceContactInfo = GetContactInfo("Trading"); invoiceContactInfo.Contact1 = GreaterThan256Characters; EditCustomer( customer.Id, "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), "Gael Ltd Invoice Address", GetAddressDetails("Invoicing"), invoiceContactInfo, "Gael Ltd Delivery Address", GetAddressDetails("Delivery"), GetContactInfo("Delivery")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Customers.Messages.ContactInfoTooLarge)); }
public void Edit_InvalidIdSupplied_CustomerEdit() { var customer = GetCustomerToEdit(); var customerRepositoryMock = MockRepository.GenerateMock<ICustomerRepository>(); customerRepositoryMock.Stub(x => x.GetById(Guid.NewGuid())).Return(null); _customerService = CustomerServiceFactory.Create(customerRepositoryMock); _customerService.Edit( customer.Id, "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), "Gael Ltd Invoice Address", GetAddressDetails("Invoicing"), GetContactInfo("Invoicing"), "Gael Ltd Delivery Address", GetAddressDetails("Delivery"), GetContactInfo("Delivery")); }
public void Create_SuccessfullyCreateCustomer_CustomerCreated() { var customerRepositoryMock = MockRepository.GenerateMock<ICustomerRepository>(); customerRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); customerRepositoryMock.Stub(x => x.GetByName("Gael Ltd")).Return(null); _customerService = CustomerServiceFactory.Create(customerRepositoryMock); _customerService.Create( Guid.NewGuid(), "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), "Gael Ltd Invoice Address", GetAddressDetails("Invoicing"), GetContactInfo("Invoicing"), "Gael Ltd Delivery Address", GetAddressDetails("Delivery"), GetContactInfo("Delivery")); customerRepositoryMock.VerifyAllExpectations(); }
public void Create_NonUniqueName_DomainValidationExceptionThrown() { var customerRepositoryStub = MockRepository.GenerateMock<ICustomerRepository>(); customerRepositoryStub.Stub(x => x.GetByName("Gael Ltd")).Return(new Customer { Name = "Gael Ltd" }); _customerService = CustomerServiceFactory.Create(customerRepositoryStub); CreateCustomer( Guid.NewGuid(), "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), "Gael Ltd Invoice Address", GetAddressDetails("Invoicing"), GetContactInfo("Invoicing"), "Gael Ltd Delivery Address", GetAddressDetails("Delivery"), GetContactInfo("Delivery")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Customers.Messages.DuplicateName)); }
public void Setup() { _customerService = CustomerServiceFactory.Create(); _domainValidationException = null; }
public void Edit_SuccessfullyEditCustomer_CustomerEdit() { var customer = GetCustomerToEdit(); var customerRepositoryMock = MockRepository.GenerateMock<ICustomerRepository>(); customerRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments(); customerRepositoryMock.Stub(x => x.GetById(customer.Id)).Return(customer); _customerService = CustomerServiceFactory.Create(customerRepositoryMock); _customerService.Edit( customer.Id, "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), "Gael Ltd Invoice Address", GetAddressDetails("Invoicing"), GetContactInfo("Invoicing"), "Gael Ltd Delivery Address", GetAddressDetails("Delivery"), GetContactInfo("Delivery")); customerRepositoryMock.VerifyAllExpectations(); }
public void Edit_NonUniqueName_DomainValidationExceptionThrown() { var nonUniqueCustomer = GetNonUniqueCustomerForEdit(); var customer = GetCustomerToEdit(); var customerRepositoryStub = MockRepository.GenerateMock<ICustomerRepository>(); customerRepositoryStub.Stub(x => x.GetById(customer.Id)).Return(customer); customerRepositoryStub.Stub(x => x.GetByName(nonUniqueCustomer.Name)).Return(nonUniqueCustomer); _customerService = CustomerServiceFactory.Create(customerRepositoryStub); CreateCustomer( customer.Id, nonUniqueCustomer.Name, GetAddressDetails("Trading"), GetContactInfo("Trading"), "Gael Ltd Invoice Address", GetAddressDetails("Invoicing"), GetContactInfo("Invoicing"), "Gael Ltd Delivery Address", GetAddressDetails("Delivery"), GetContactInfo("Delivery")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Customers.Messages.DuplicateName)); }