public void FullNameLastNameEmpty() { //arrange Customer customer = new Customer(); customer.FirstName = "Amy"; string expected = "Amy"; //act string actual = customer.FullName; //assert Assert.AreEqual(expected, actual); }
public void RetreiveExistingWithAddress() { //Arrange var customerRepository = new CustomerRepository(); var expected = new Customer(1) { EmailAddress = "xxx", FirstName = "xxx", LastName = "xxx", AddressList = new List<Address>() { new Address() { AddressType = 1, StreetLine1 = "xxx", StreetLine2 = "xxx", City = "xxx", StateProvince = "xxx", PostCode = "xxx", Country = "xxx" }, new Address() { AddressType = 2, StreetLine1 = "xxx", StreetLine2 = "xxx", City = "xxx", StateProvince = "xxx", PostCode = "xxx", Country = "xxx" } } }; //Act var actual = customerRepository.Retreive(1); //Assert Assert.AreEqual(expected.CustomerId, actual.CustomerId); Assert.AreEqual(expected.EmailAddress, actual.EmailAddress); //more here for (int i = 0; i < 1; i++) { Assert.AreEqual(expected.AddressList[i].AddressType, actual.AddressList[i].AddressType); Assert.AreEqual(expected.AddressList[i].StreetLine1, actual.AddressList[i].StreetLine1); //more here } }
public void ValidateInvalid() { //arrange var customer = new Customer(); customer.LastName = "Dylan"; customer.EmailAddress = ""; var expected = false; //act var actual = customer.Validate(); //assert Assert.AreEqual(expected, actual); }
public void FullNameTestValid() { //arrange Customer customer = new Customer(); customer.FirstName = "Amy"; customer.LastName = "Simmons"; string expected = "Simmons, Amy"; //act string actual = customer.FullName; //assert Assert.AreEqual(expected, actual); }
public Customer Retreive(int customerId) { //code that retreives the defined customer Customer customer = new Customer(customerId); customer.AddressList = addressRepository.RetreiveByCustomerId(customerId).ToList(); if (customerId == 1) { customer.EmailAddress = "xxx"; customer.FirstName = "xxx"; customer.LastName = "xxx"; } return customer; }
public void StaticTest() { //arrange var c1 = new Customer(); c1.FirstName = "Bilbo"; Customer.InstanceCount += 1; var c2 = new Customer(); c2.FirstName = "Frodo"; Customer.InstanceCount += 1; var c3 = new Customer(); c3.FirstName = "Rosie"; Customer.InstanceCount += 1; //assert Assert.AreEqual(Customer.InstanceCount, 3); }
public bool Save(Customer customer) { //code that saves the defined customer var success = true; if (customer.HasChanges && customer.IsValid) { if (customer.IsNew) { //call an insert stored procedure } else { //call an update stored procedure } } return success; }
public void RetreiveExisting() { //Arrange var customerRepository = new CustomerRepository(); var expected = new Customer(1) { EmailAddress = "xxx", FirstName = "xxx", LastName = "xxx" }; //Act var actual = customerRepository.Retreive(1); //Assert Assert.AreEqual(expected.CustomerId, actual.CustomerId); Assert.AreEqual(expected.EmailAddress, actual.EmailAddress); Assert.AreEqual(expected.FirstName, actual.FirstName); Assert.AreEqual(expected.LastName, actual.LastName); }