Esempio n. 1
0
 private void seed(SoilMatesContext testcontext)
 {
     testcontext.Customers.AddRange(testCustomers);
     testcontext.Managers.AddRange(testManagers);
     testcontext.Inventories.AddRange(testInventories);
     testcontext.Locations.AddRange(testLocations);
     testcontext.Products.AddRange(testProducts);
     testcontext.SaveChanges();
 }
Esempio n. 2
0
        public void GetProductShouldGet()
        {
            var options = new DbContextOptionsBuilder <SoilMatesContext>().UseInMemoryDatabase("GetProductShouldGet").Options;

            using var testContext = new SoilMatesContext(options);
            seed(testContext);

            using var assertContext = new SoilMatesContext(options);
            repo = new DBrepo(assertContext);

            var result = repo.GetProduct(6);

            Assert.NotNull(result);
            Assert.Equal("Aloe", result.Name);
        }
Esempio n. 3
0
        public void AddProductShouldAdd()
        {
            //arrange
            var options = new DbContextOptionsBuilder <SoilMatesContext>().UseInMemoryDatabase("AddProductShoudAdd").Options;

            using var testContext = new SoilMatesContext(options);
            repo = new DBrepo(testContext);

            //act
            repo.AddProduct(testProduct);

            //assert
            using var assertContext = new SoilMatesContext(options);
            Assert.NotNull(assertContext.Products.SingleAsync(n => n.Name == testProduct.Name));
        }
Esempio n. 4
0
        public void AddOrderShouldAdd()
        {
            //arrange
            var options = new DbContextOptionsBuilder <SoilMatesContext>().UseInMemoryDatabase("AddOrderShoudAdd").Options;

            using var testContext = new SoilMatesContext(options);
            repo = new DBrepo(testContext);

            //act
            repo.AddOrder(testOrder);

            //assert
            using var assertContext = new SoilMatesContext(options);
            Assert.NotNull(assertContext.Orders.SingleAsync(n => n.OrderId == testOrder.OrderId));
        }
Esempio n. 5
0
        public void AddLocationShouldAdd()
        {
            //arrange
            var options = new DbContextOptionsBuilder <SoilMatesContext>().UseInMemoryDatabase("AddLocationShoudAdd").Options;

            using var testContext = new SoilMatesContext(options);
            repo = new DBrepo(testContext);

            //act
            repo.AddLocation(testLocation);

            //assert
            using var assertContext = new SoilMatesContext(options);
            Assert.NotNull(assertContext.Inventories.SingleAsync(n => n.InventoryId == testInventory.InventoryId));
        }
        public void GetALLManagersProductsShouldGet()
        {
            var options = new DbContextOptionsBuilder <SoilMatesContext>().UseInMemoryDatabase("GetAllManagersGet").Options;

            using var testContext = new SoilMatesContext(options);
            seed(testContext);

            using var assertContext = new SoilMatesContext(options);
            repo = new DBrepo(assertContext);

            var result = repo.GetAllManagers();

            Assert.NotNull(result);
            Assert.Equal(2, result.Count);
        }
        public void GetManagerByEmailShouldGet()
        {
            var options = new DbContextOptionsBuilder <SoilMatesContext>().UseInMemoryDatabase("GetManagerByEmailShouldGet").Options;

            using var testContext = new SoilMatesContext(options);
            seed(testContext);

            using var assertContext = new SoilMatesContext(options);
            repo = new DBrepo(assertContext);

            var result = repo.GetManagerByEmail("*****@*****.**");

            Assert.NotNull(result);
            Assert.Equal("Babish", result.Name);
        }
        public void GetCustomerByEmailShouldGet()
        {
            var options = new DbContextOptionsBuilder <SoilMatesContext>().UseInMemoryDatabase("GetCustomerByEmailShouldGet").Options;

            using var testContext = new SoilMatesContext(options);
            seed(testContext);

            using var assertContext = new SoilMatesContext(options);
            repo = new DBrepo(assertContext);

            var result = repo.GetCustomerByEmail("*****@*****.**");

            Assert.NotNull(result);
            Assert.Equal("Will", result.Name);
        }
 public MainMenu(SoilMatesContext context)
 {
     repository       = new DBrepo(context);
     this._loginMenu  = new LoginMenu(repository);
     this._signupMenu = new SignupMenu(repository);
 }