Ejemplo n.º 1
0
        public void ServiceLayer_ShopBasket_INF_Test()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <EfstoreContext>()
                          .UseInMemoryDatabase(databaseName: "WebstoreDB").Options;

            //ACT
            using (var op = new EfstoreContext(options))
            {
                Shopbasket sb = new Shopbasket();
                sb.Product_id = 1;
                sb.Name       = "Adiddas";
                sb.OrderLines = "4";
                sb.Quantity   = 4;

                var PS = new ShopbasketService(op);
                PS.Add(sb);

                //Assert
                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new EfstoreContext(options))
                {
                    Assert.AreEqual(1, context.shopbaskets.Count());
                    // Assert.AreEqual("Adiddas", context.shopbaskets.Single().Name);
                    Assert.AreEqual("4", context.shopbaskets.Single().OrderLines);
                }

                {
                }
            }
        }
Ejemplo n.º 2
0
        public void OnPostBasket(int id)
        {
            prod = _db.prod.ToList();


            var context = new EfstoreContext();

            SS = new ShopbasketService(context);

            Shopbasket sb = new Shopbasket();

            foreach (Products p in prod)
            {
                sb.ClothingID = p.ClothingID;
                sb.Name       = p.name;
                sb.Quantity   = 1;
                sb.OrderLines = "1";
                sb.Product_id = 1;
            }
            SS.Add(sb);
        }
Ejemplo n.º 3
0
        public Shopbasket Update(Shopbasket updateShopbasket)
        {
            _ctx.shopbaskets.Update(updateShopbasket);

            return(updateShopbasket);
        }
Ejemplo n.º 4
0
 public Shopbasket Add(Shopbasket P)
 {
     _ctx.shopbaskets.Add(P);
     Commit();
     return(P);
 }