Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
 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"));
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
 public void Setup()
 {
     _customerService = CustomerServiceFactory.Create();
     _domainValidationException = null;
 }
Ejemplo n.º 7
0
 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();
 }
Ejemplo n.º 8
0
 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));
 }