public virtual void FindAll() { CreateCustomer(); var result = CustomerServiceAdapter.Execute(s => s.FindAll()); Assert.IsTrue(result.Customers.Count == 1, "One customer instance was expected"); }
public virtual void CheckFindAllNotification() { var result = CustomerServiceAdapter.Execute(s => s.FindAll()); Assert.IsTrue(result.Customers.Count == 0, "No customers were expected"); Assert.IsTrue(result.Response.HasWarning, "Warning flag is not set"); Assert.IsTrue(result.Response.BusinessWarnings.Count() == 1, "One warning was only expected"); Assert.AreEqual(result.Response.BusinessWarnings.Single().Message, "No customer instances were found"); CreateCustomer(); result = CustomerServiceAdapter.Execute(s => s.FindAll()); Assert.IsFalse(result.Response.HasWarning, "Warning flag is set"); }
public virtual void CreateCustomer() { var dto = new CustomerDto { FirstName = "Joe", LastName = "Bloggs", Telephone = "999-8888" }; CustomerInstance = CustomerServiceAdapter.Execute(s => s.CreateNewCustomer(dto)); Assert.IsFalse(CustomerInstance.Id == 0, "Customer Id should have been updated"); Assert.AreEqual(CustomerInstance.FirstName, dto.FirstName, "First Name are different"); }
public virtual void UpdateCustomer() { CreateCustomer(); var id = CustomerInstance.Id; var dto = new CustomerDto { Id = id, FirstName = "Joe", LastName = "Bloggs", Telephone = "888-8888" }; CustomerInstance = CustomerServiceAdapter.Execute(s => s.UpdateCustomer(dto)); Assert.IsTrue(CustomerInstance.Id == id, "Customer Id should have remainded the same"); Assert.AreEqual(CustomerInstance.Telephone, "888-8888", "Incorrect telephone after the update"); }
public virtual void CreateAddress() { CreateCustomer(); AddressInstance = AddressServiceAdapter.Execute(s => s.CreateNewAddress(new AddressDto { CustomerId = CustomerInstance.Id, Street = "23 Thames Street", City = "London", PostCode = "16A", Country = "England" })); Assert.AreEqual(CustomerInstance.Id, AddressInstance.CustomerId, "incorrect customer id was found"); Assert.AreNotEqual(0, AddressInstance.Id, "incorrect address id was returned"); var customer = CustomerServiceAdapter.Execute(s => s.GetById(CustomerInstance.Id)); Assert.AreEqual(1, customer.Addresses.Count, "One address was expected"); }
public virtual void CreateDuplicateCustomer() { CreateCustomer(); var dto = new CustomerDto { FirstName = "Joe", LastName = "Bloggs", Telephone = "999-8888" }; try { var result = CustomerServiceAdapter.Execute(s => s.CreateNewCustomer(dto)); Assert.IsTrue(result.Response.HasException, "An exception was expected"); } catch (BusinessException ex) { Assert.AreEqual(ex.Message, "A customer instance already exist with these first and last names."); } }