public void AddCustomerShouldAddCustomer() { using (var context = new StoreDBContext(options)) { ICustomerRepository _repo = new CustomerRepoDB(context); _repo.AddCustomer ( new Model.Customer { Id = 2, CustomerName = "Batman", CustomerEmail = "*****@*****.**", CustomerPasswordHash = "Pa55WordI23", CustomerPhone = "7948062079", CustomerAddress = "Batstreet, Batcity, Batstate Batcode" } ); } //use the context to check the state of the db directly when asserting. using (var assertContext = new StoreDBContext(options)) { var result = assertContext.Customers.FirstOrDefault(customer => customer.CustomerName == "Batman"); Assert.NotNull(result); Assert.Equal("Batman", result.CustomerName); } }
public void GetCustomerByEmailShouldRetuenCustomer() { using (var context = new StoreDBContext(options)) { ICustomerRepository _repo = new CustomerRepoDB(context); var foundCustomer = _repo.GetCustomerByEmail("*****@*****.**"); Assert.NotNull(foundCustomer); Assert.Equal("*****@*****.**", foundCustomer.CustomerEmail); } }
public void GetAllCustomersShouldReturnAllCustomers() { using (var context = new Entity.StoreDBContext(options)) { //Arrange ICustomerRepository _repo = new CustomerRepoDB(context, new StoreMapper()); //Act var customer = _repo.GetCustomers(); Assert.Equal(2, customer.Count); } }
public void GetAllCustomersShouldReturnAllCustomers() { using (var context = new Entity.wssdbContext(options)) { //Arrange the test context CustomerRepoDB _repo = new CustomerRepoDB(context, mapper); //Act var customers = _repo.GetAllCustomers(); //Assert Assert.Equal(3, customers.Count); } }
public void GetAllCustomersShouldReturnAllCustomers() { //This is a using block, at the end of the execution of the code surrounded by the block, the //unmanaged resource is going to be disposed of using (var context = new StoreDBContext(options)) { //Arrange ICustomerRepository _repo = new CustomerRepoDB(context); //Act var customers = _repo.GetCustomers(); Assert.Equal(2, customers.Count); } }
//Drink drink = new Drink(); public void Start() { bool startMenu = true; do { Console.WriteLine("Welcome to Dozen! Are you a manager or a customer?"); Console.WriteLine("[0] Customer Menu"); Console.WriteLine("[1] Manager"); Console.WriteLine("[2] Exit"); //get user input Console.WriteLine("Enter a number: "); string userInput = Console.ReadLine(); var drinkrepo = new DrinkRepositoryDB(); var mapper = new Mapper(); var customerRepo = new CustomerRepoDB(context, mapper); var customerBL = new CustomerBL(customerRepo); var locationRepo = new LocationRepositoryDB(context, mapper); var locationBL = new LocationBL(locationRepo); var orderRepoDB = new OrderRepositoryDB(context, mapper); var orderBL = new OrderBL(orderRepoDB); var inventoryRepoDB = new InventoryRepoDB(context, mapper); var inventoryBL = new InventoryBL(inventoryRepoDB); var drinkBL = new DrinkBL(drinkrepo); switch (userInput) { case "0": CustomerMenu customerMenu = new CustomerMenu(drinkBL, customerBL, locationBL, orderBL, inventoryBL); customerMenu.Start(); break; case "1": ManagerMenu managerMenu = new ManagerMenu(locationBL, orderBL, inventoryBL, customerBL); managerMenu.Start(); break; case "2": startMenu = false; break; default: Console.WriteLine("Invalid input! Try again"); break; } } while (startMenu); }
public void UpdateCustomerShouldUpdate() { using (var context = new StoreDBContext(options)) { ICustomerRepository _repo = new CustomerRepoDB(context); _repo.UpdateCustomer( new Model.Customer { Id = 1, CustomerName = "Aquaperson", CustomerEmail = "*****@*****.**", CustomerPasswordHash = "PassW0rd12E", CustomerPhone = "9702608497", CustomerAddress = "a street, a city, a state zipcode" } ); } }
public void AddCustomerShouldAddCustomer() { using (var context = new Entity.wssdbContext(options)) { CustomerRepoDB _repo = new CustomerRepoDB(context, mapper); //Act with a test context _repo.AddNewCustomer ( new Model.Customer("Test User") ); } //use a diff context to check if changes persist to db using (var assertContext = new Entity.wssdbContext(options)) { //Assert with a different context var result = assertContext.Customers.FirstOrDefault(cust => cust.Id == 4); Assert.NotNull(result); Assert.Equal("Test User", result.CName); } }
public void DeleteShouldDelete() { using (var context = new StoreDBContext(options)) { ICustomerRepository _repo = new CustomerRepoDB(context); _repo.DeleteCustomer( new Model.Customer { Id = 1, CustomerName = "Aquaman", CustomerEmail = "*****@*****.**", CustomerPasswordHash = "PassW0rd12E", CustomerPhone = "9702608497", CustomerAddress = "a street, a city, a state zipcode" } ); } using (var assertContext = new StoreDBContext(options)) { var result = assertContext.Customers.Find(1); Assert.Null(result); } }
public CustomerBL(CustomerRepoDB repo) { _repo = repo; }