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(); }
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); }
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)); }
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)); }
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); }