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

                {
                }
            }
        }
Exemplo n.º 2
0
        public void OnPostDelete(int ClothingID)
        {
            var context = new EfstoreContext();

            SS = new ShopbasketService(context);


            SS.Delete(4);
        }
Exemplo n.º 3
0
        private List <Shopbasket> GetProdBasket(int i)
        {
            var context = new EfstoreContext();

            SS = new ShopbasketService(context);
            List <Shopbasket> pd = SS.GetShopBasketById(i);

            return(pd);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public userinformation one()
        {
            EfstoreContext efx = new EfstoreContext();
            // UserinformationService ser1 = new UserinformationService(efx);


            userinformation sb = new userinformation();
            ////sb.id = 1;
            //sb.fullname = "Hansen";
            //sb.Address = "Hansenvej 1";
            //sb.dateofbirth = DateTime.Now;
            //sb.CountryCode = 1100;
            //sb.city = "hansenberg";
            //sb.gender = "M";
            //sb.paymentO = "MasterCard";
            //ser1.Add(sb);

            ShopbasketService sb1 = new ShopbasketService(efx);

            sb1.Delete(0);

            return(sb);



            //Shopbasket sb = new Shopbasket();


            //IQueryable<Products> ps =       prod1.GetProductById(2);



            //var context = new EfstoreContext();
            //var studentsWithSameName = context.Products
            //                                  .Where(s => s.ClothingID == 2)
            //                                  .ToList();

            //List<Products> pd = studentsWithSameName.ToList<Products>();
        }