public HojaRecuentoBS(RepoDB db, IAlmacenZPBS almacen, ICabeceraRecuentoBS cabecera, ICenterBS center, IConfiguration conf) : base(db) { _conf = conf; aBS = almacen; cBS = cabecera; cnBS = center; }
public EntityBS(RepoDB dbBBDD) { if (db == null) { this.db = dbBBDD; } }
public void GetAllProductsShouldReturnAllProducts() { using (var context = new Entity.MochaMomentDBContext(options)) { IRepository _repo = new RepoDB(context); var products = _repo.GetAllProducts(); Assert.Equal(2, products.Count); } }
public void GetLocationByName() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); Model.Location result = _repo.GetLocation("WA-Seattle"); Assert.NotNull(result); Assert.Equal(1, result.Id); } }
public void GetProductByBarcode() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); Model.Product result = _repo.GetProduct("j-g-t-s-01"); Assert.NotNull(result); Assert.Equal(1, result.Id); } }
public void GetCustomerByNameShouldReturnCorrespondingCustomer() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); var result = _repo.GetCustomer("2063317069"); Assert.NotNull(result); Assert.Equal("Fang", result.LasttName); } }
public void GetAllBranchLocations() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); List <Model.Location> result = _repo.GetAllLocations(); Assert.NotNull(result); Assert.Equal(1, result.Count); } }
public void GetAllInventories() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); Model.Location location = _repo.GetLocation("WA-Seattle"); HashSet <Model.Item> result = _repo.GetAllInventories(location); Assert.NotNull(result); Assert.Equal(1, result.Count); } }
public static IMenu GetMenu(string menuType) { //configure var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); //connect string connectionString = configuration.GetConnectionString("StoreAppDB"); //Console.WriteLine(connectionString); //option DbContextOptions <StoreAppDBContext> options = new DbContextOptionsBuilder <StoreAppDBContext>() .UseSqlServer(connectionString) .Options; //context var context = new StoreAppDBContext(options); IRepository repo = new RepoDB(context); IValidationService inputValidation = new ValidationService(); ICustomerBL customerBL = new CustomerBL(repo); ILocationBL locationBL = new LocationBL(repo); IProductBL productBL = new ProductBL(repo); IInventoryBL inventoryBL = new InventoryBL(repo); IOrderBL orderBL = new OrderBL(repo); switch (menuType.ToLower()) { case "main": return(new MainMenu()); case "branch": return(new BranchMenu(locationBL, inputValidation)); case "product": return(new ProductMenu(productBL, inputValidation)); case "inventory": return(new InventoryMenu(locationBL, productBL, inventoryBL, orderBL, inputValidation)); case "customer": return(new CustomerMenu(customerBL)); case "order": return(new OrderMenu(customerBL, locationBL, productBL, inventoryBL, orderBL, inputValidation)); default: return(null); } }
protected void ddlRepo_SelectedIndexChanged(object sender, EventArgs e) { if (ddlRepo.SelectedValue == "DB") { Session["base"] = new RepoDB(); LogOut(); } else if (ddlRepo.SelectedValue == "TXT") { Session["base"] = new RepoText(); LogOut(); } }
public void AddProductShouldAddProduct() { using (var context = new Entity.MochaMomentDBContext(options)) { IRepository _repo = new RepoDB(context); _repo.AddProduct(new Model.Product("Espresso", 1.99, "Espresso?")); } using (var assertContext = new Entity.MochaMomentDBContext(options)) { var result = assertContext.Products.FirstOrDefault(product => product.ProductId == 3); Assert.NotNull(result); Assert.Equal("Espresso", result.ItemName); } }
public void UpdateInventoryByProductId() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); Model.Product product = _repo.GetProductById(1); _repo.UpdateInventory(product, 10); var result = _repo.GetInventory(product); Assert.Equal("j-g-t-s-01", product.Barcode); Assert.Equal(10, result.Quantity); } }
//Test Read Ops // When testing methods that do not state of the data public void GetAllCustomersShouldAddCustomers() { //putting in a test context/ connection to our test db using (var context = new Entity.StoreDBContext(options)) { //Arrange IRepository _repo = new RepoDB(context); //Act var stores = _repo.GetAllCustomers(); //Assert Assert.Equal(2, stores.Count); } }
public void GetAllRestaurantsShouldReturnAllRestaurants() { //putting in a test context/ connection to our test db using (var context = new Entity.RestaurantDBContext(options)) { //Arrange IRepository _repo = new RepoDB(context); //Act var restaurants = _repo.GetAllRestaurants(); //Assert Assert.Equal(2, restaurants.Count); } }
public void AddProduct() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); _repo.AddProduct( new Model.Product("BBT", 3.00m, "BBT01") ); } using (var assertContext = new Entity.StoreAppDBContext(options)) { //IRepository _repo = new RepoDB(assertContext); var result = assertContext.Products.FirstOrDefault(c => c.Id == 3); Assert.NotNull(result); Assert.Equal("BBT", result.Name); } }
public void AddCustomerShoudAddCustomer() { using (var context = new Entity.StoreAppDBContext(options)) { IRepository _repo = new RepoDB(context); _repo.AddCustomer( new Model.Customer("Jia", "W", "Fang", "2063317069") ); } using (var assertContext = new Entity.StoreAppDBContext(options)) { //IRepository _repo = new RepoDB(assertContext); var result = assertContext.Customers.FirstOrDefault(c => c.Id == 2); Assert.NotNull(result); Assert.Equal("Jia", result.FirstName); } }
public AlbaranCompraBS(RepoDB db, ILineBS line, IProductBS product, IProviderRateBS providerRate, IAlbaranLineaBS albaranLinea, IHistoricoPedidoBS historicoPedido, IHeaderOrderBS headerOrder, IConfiguration conf) : base(db) { _conf = conf; iBS = line; prBS = product; pBS = providerRate; aBS = albaranLinea; hBS = historicoPedido; hoBS = headerOrder; }
public void AddLineItemShouldAddLineItem() { using (var context = new Entity.MochaMomentDBContext(options)) { IRepository _repo = new RepoDB(context); _repo.AddCustomer(new Model.Customer("firstName", "lastName", "birthdate", "phone#", "email", "Mailing Address")); _repo.AddLocation(new Model.Location("name", "address", "city", "state")); _repo.AddProduct(new Model.Product("name", 1.99, "description")); _repo.AddOrder(new Model.Order(1, 1, 1, 1.99, ""), new Model.Location("name", "address", "city", "state"), new Model.Customer("firstName", "lastName", "birthdate", "phone#", "email", "Mailing Address")); _repo.AddLineItem(new Model.LineItem(1, 1, 1), new Model.Product("name", 1.99, "description")); } using (var assertContext = new Entity.MochaMomentDBContext(options)) { var result = assertContext.LineItems.FirstOrDefault(li => li.LineItemId == 1); Assert.NotNull(result); Assert.Equal(1, result.Quantity); } }
public void addProductsShouldAddProducts() { using (var context = new Entity.StoreDBContext(options)) { IRepository _repo = new RepoDB(context); _repo.AddStore ( new Model.Store("Patrick's Peppers", "Austin", "TX") ); } //use a diff context to check if changes persist to db using (var assertContext = new Entity.StoreDBContext(options)) { var result = assertContext.Stores.FirstOrDefault(store => store.Id == 3); Assert.NotNull(result); assertContext.Equal("Austin", result.City); } }
public void AddRestaurantShouldAddRestaurant() { using (var context = new Entity.RestaurantDBContext(options)) { IRepository _repo = new RepoDB(context); //Act with a test context _repo.AddRestaurant ( new Model.Restaurant("Whataburger", "Dallas", "TX") ); } //use a diff context to check if changes persist to db using (var assertContext = new Entity.RestaurantDBContext(options)) { //Assert with a different context var result = assertContext.Restaurants.FirstOrDefault(restaurant => restaurant.Id == 3); Assert.NotNull(result); Assert.Equal("Dallas", result.City); } }
public void TestLocationBeingAdded() { Location c = new Location(){LocationName = "name", Address="address"}; using (var context = new StoreDBContext(options)){ context.Database.EnsureDeleted(); context.Database.EnsureCreated(); IRepository _repo = new RepoDB(context); _repo.AddLocation(c); } //Using a new context check for Location using (var context = new StoreDBContext(options)){ IRepository _repo = new RepoDB(context); List<Location> cs = _repo.GetAllLocations(); Location cdb = cs.ToArray()[0]; Assert.Equal(c.LocationID, cdb.LocationID); Assert.Equal(c.LocationName, cdb.LocationName); Assert.Equal(c.Address, cdb.Address); Assert.True(cs.Count == 1); context.Database.EnsureDeleted(); } }
public void TestProductBeingAdded() { // var mockRepo = new Mock<IRepository>(); Product c = new Product("My Product", 12.99); using (var context = new StoreDBContext(options)){ context.Database.EnsureDeleted(); context.Database.EnsureCreated(); IRepository _repo = new RepoDB(context); _repo.AddProduct(c); } //Using a new context check for Product using (var context = new StoreDBContext(options)){ IRepository _repo = new RepoDB(context); List<Product> cs = _repo.GetAllProducts(); Product cdb = cs.ToArray()[0]; Assert.Equal(c.Name, cdb.Name); Assert.Equal(c.Price, cdb.Price); Assert.True(cs.Count == 1); Assert.Equal(c.ProductID, cdb.ProductID); context.Database.EnsureDeleted(); } }
public ProductCategoryBS(RepoDB db, IConfiguration conf) : base(db) { _conf = conf; }
public PedVentaCabBS(RepoDB db, IConfiguration conf) : base(db) { _conf = conf; }
public ProviderRateBS(RepoDB db, IConfiguration conf) : base(db) { _conf = conf; }
public AlmacenZPBS(RepoDB db, IConfiguration conf) : base(db) { _conf = conf; }
public SubCentreBS(RepoDB db, IConfiguration conf) : base(db) { _conf = conf; }
public CustomerCenterBS(RepoDB db, IConfiguration conf) : base(db) { _conf = conf; }
public CentroBS(RepoDB dbBAse) { this.db = dbBAse; }
public HeaderOrderBS(IProviderBS provider, RepoDB db, IConfiguration conf) : base(db) { _conf = conf; pBS = provider; }