Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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);
     }
 }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        //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);
        }
Exemplo n.º 7
0
 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"
         }
             );
     }
 }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 public CustomerBL(CustomerRepoDB repo)
 {
     _repo = repo;
 }