public void WriteToFileTest() { //Arrange var changeItems = new List<ILoggable>(); var customer = new Customer(1) { Email = "*****@*****.**", FirstName = "Rich", LastName = "Strong", AddressList = null }; changeItems.Add(customer as ILoggable); var product = new Product(2) { ProductName = "Beef meat", ProductDescription="Scottish beef ", CurrentPrice = 8M }; changeItems.Add(product as ILoggable); //Act LoggingServices.WriteToFile(changeItems); //Assert //Nothing to Assert >> }
public void RetrieveExistingWithAddress() { //Arrange var customerRepository = new CustomersRepository(); var expected = new Customer(1) { Email = "*****@*****.**", FirstName = "strong", LastName = "unknow", AddressList = new List<Address>() { new Address() { AddressType = 1, StreetLineOne = "Good Year", StreetLineTwo = "Good Harvest", City = "Brigton", State = "Shine", Country = "Central UK", PostCode = "144HU" }, new Address() { AddressType = 2, StreetLineOne = "Good Year 2", StreetLineTwo = "Good Harvest 2", City = "London", State = "London", Country = "Central UK 2", PostCode = "144HU 2" } } }; //Act var actual = customerRepository.Retrieve(1); //Assert Assert.AreEqual(expected.CustomerID,actual.CustomerID); Assert.AreEqual(expected.Email,actual.Email); 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].StreetLineOne,actual.AddressList[i].StreetLineOne); 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].State); Assert.AreEqual(expected.AddressList[i].PostCode,actual.AddressList[i].PostCode); } }
public void LastNameEmpty() { Customer customer = new Customer(); customer.FirstName = "bilbo"; string expected = "bilbo"; string actual = "bilbo"; Assert.AreEqual(expected,actual); }
public void FirstNameEmpty() { Customer customer = new Customer(); customer.LastName = " strong"; string expected = " strong"; string actual = customer.FullName; Assert.AreEqual(expected, actual); }
public void ValidateValid() { // Arrange var customer = new Customer(); customer.LastName = "strong"; customer.Email = "*****@*****.**"; var expected = true; // Act var actual = customer.Validate(); // Assert Assert.AreEqual(expected,actual); }
public Customer Retrieve(int customerID) { //Create the instance of the Customer class Customer customer = new Customer(customerID); customer.AddressList = addressRepository.RetrieveByCustomerID(customerID) .ToList(); // to return a populate Customer; if (customerID == 1) { customer.Email = "*****@*****.**"; customer.FirstName = "unknown"; customer.LastName = "strong"; } return customer; }
public void StaticTest() { //Arrange var varOne = new Customer(); varOne.FirstName = "bilbo"; Customer.InstanceCount += 1; var varTwo = new Customer(); varTwo.FirstName = "strong"; Customer.InstanceCount += 1; var varThree = new Customer(); varThree.FirstName = "Rosse"; Customer.InstanceCount += 1; //Act //Assert Assert.AreEqual(3,Customer.InstanceCount); }
public void FuulNameTestValid() { #region Arrange Customer customer = new Customer(); customer.FirstName = "bilbo"; customer.LastName = "strong"; string expected = "strong,bilbo"; #endregion Arrange #region Act string actual = customer.FullName; #endregion Act #region Assert Assert.AreEqual(expected,actual); #endregion Assert }
public void RetriveExiting() { //Arrange var customerRepository = new CustomersRepository(); var expected = new Customer(1) { Email = "*****@*****.**", FirstName = "unknown", LastName = "strong" }; //Act var actual = customerRepository.Retrieve(1); //Assert //Assert.AreEqual(expected,actual); Assert.AreEqual(expected.CustomerID,actual.CustomerID); Assert.AreEqual(expected.Email,actual.Email); Assert.AreEqual(expected.FirstName,actual.FirstName); Assert.AreEqual(expected.LastName,actual.LastName); }
public void ValidateMissingLastName() { //Arrange var customer = new Customer(); customer.Email = "*****@*****.**"; //Act var expected = false; var actual = customer.Validate(); //Assert Assert.AreEqual(expected,actual); }