public void WriteToFileTest() { // Arrange var changedItems = new List<ILoggable>(); var customer = new Customer(1) { EmailAddress = "*****@*****.**", FirstName = "Frodo", LastName = "Baggins", AddressList = null }; changedItems.Add((ILoggable) customer); var product = new Product(2) { ProductName = "Rake", ProductDescription = "Garden Rake with Steel Head", CurrentPrice = 6M }; changedItems.Add((ILoggable) product); // Act LoggingService.WriteToFile(changedItems); //Assert //Nothing here to assert }
public void RetrieveExistingWithAddress() { //Arrange var customerRepository = new CustomerRepository(); var expected = new Customer(1) { EmailAddress = "*****@*****.**", FirstName = "Frodo", LastName = "Baggins", AddressList = new List<Address>() { new Address() { AddressType = 1, StreetLine1 = "Bad End", StreetLine2 = "Bagshot row", City = "Hobbiton", State = "Shire", Country = "Middle Earth", PostalCode = "144" }, new Address() { AddressType = 2, StreetLine1 = "Green Dragon", City = "Bywater", State = "Shire", Country = "Middle Earth", PostalCode = "144" } } }; //Act var actual = customerRepository.Retrieve(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); 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); Assert.AreEqual(expected.AddressList[i].City, actual.AddressList[i].City); Assert.AreEqual(expected.AddressList[i].State, actual.AddressList[i].State); Assert.AreEqual(expected.AddressList[i].Country, actual.AddressList[i].Country); Assert.AreEqual(expected.AddressList[i].PostalCode, actual.AddressList[i].PostalCode); } }
/// <summary> /// Retrieve one customer /// </summary> /// <param name="customerId"></param> /// <returns></returns> public Customer Retrieve(int customerId) { var customer = new Customer(1); customer.AddressList = addressRepository.RetrieveByCustomerId(customerId).ToList(); if (customerId == 1) { customer.EmailAddress = "*****@*****.**"; customer.FirstName = "Frodo"; customer.LastName = "Baggins"; } return customer; }
public void FullNameLastNameEmpty() { //Arrange var customer = new Customer() { FirstName = "Bilbo" }; string expected = "Bilbo"; //Act string actual = customer.FullName; //Assert Assert.AreEqual(expected, actual); }
public void StaticTest() { // Arrange var c1 = new Customer() {FirstName = "Bilbo"}; Customer.InstanceCount += 1; var c2 = new Customer() {FirstName = "Frodo"}; Customer.InstanceCount += 1; var c3 = new Customer() {FirstName = "Rosie"}; Customer.InstanceCount += 1; //Act var expected = 3; //Assert Assert.AreEqual(expected, Customer.InstanceCount); }
public void FullNameTestValid() { //Arrange var customer = new Customer() { FirstName = "Bilbo", LastName = "Baggins" }; string expected = "Baggins, Bilbo"; //Act string actual = customer.FullName; //Assert Assert.AreEqual(expected, actual); }
public void RetrieveExiting() { // Arrange var customerRepository = new CustomerRepository(); var expected = new Customer(1) { EmailAddress = "*****@*****.**", FirstName = "Frodo", LastName = "Baggins" }; // Act var actual = customerRepository.Retrieve(1); // Assert // Assert.AreEqual(expected, actual); Assert.AreEqual(expected.CustomerId, actual.CustomerId); Assert.AreEqual(expected.EmailAddress, actual.EmailAddress); Assert.AreEqual(expected.FirstName, actual.FirstName); Assert.AreEqual(expected.LastName, actual.LastName); }
public void ValidateMissingLastName() { // Arrange var customer = new Customer() { EmailAddress = "*****@*****.**" }; var expect = false; // Act var actual = customer.Validate(); // Assert Assert.AreEqual(expect, actual); }
public void ValidateValid() { // Arrange var customer = new Customer() { LastName = "Baggins", EmailAddress = "*****@*****.**" }; var expect = true; // Act var actual = customer.Validate(); // Assert Assert.AreEqual(expect, actual); }