public CartSteps(ScenarioContext scenarioContext)
 {
     _driver  = scenarioContext["WEB_DRIVER"] as IWebDriver;
     products = new productsController(scenarioContext);
     cart     = new CartController(scenarioContext);
     checkout = new CheckoutController(scenarioContext);
 }
Exemple #2
0
        public void TestInitialize()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context = new ApplicationDbContext(options);
            products = new List <Product>();

            Product mockProduct = new Product
            {
                productId   = 55,
                productName = "A product"
            };

            products.Add(new Product
            {
                productId   = 20,
                productName = "Some Model",
                productType = 38,
                color       = "Red",
                price       = mockProduct
            });

            products.Add(new Product
            {
                productId   = 200,
                productName = "Some Model",
                color       = 770,
                price       = "Blue",
                productType = mockProduct
            });

            products.Add(new Product
            {
                productId   = 300,
                productName = "Some Model",
                productType = mockProduct,
                color       = "Green",
                Price       = 789
            });

            foreach (var k in products)
            {
                // add each product to in-memory db
                _context.Equipments.Add(k);
            }
            _context.SaveChanges();

            productsController = new ProductsController(_context);
        }
Exemple #3
0
        public void AddProduct()
        {
            var owner = TestUtils.addTestMember();
            var th    = new TestHelpers();

            th.FakeHttpContext();
            HttpContextBase httpContext = th.httpContext.Object;
            var             controller  = new productsController();
            var             context     = new ControllerContext(new RequestContext(httpContext, new RouteData()), controller);

            controller.ControllerContext = context;

            // product category
            var mastercatid     = repository.AddMasterProductCategory("Ingredients").id;
            var productcategory = new productCategory();

            productcategory.masterID = mastercatid;
            //productcategory.subdomain = s;
            var pcid = repository.AddProductCategory(productcategory, 0);

            // stock unit
            var su = new stockUnit();

            su.unitID = repository.AddMasterStockUnit("bottle").id;
            su.owner  = owner;
            var suid = repository.AddStockUnit(su);

            controller.Session["id"] = owner;
            // supplier
            var supid  = repository.GetProductSupplier("Example Supplier Co.").id;
            var result = controller.Create("TEST001", "Tomato Sauce", "red tomato sauce\nvery yummy", pcid,
                                           suid, "1", "2", "", "", "", new[] { "2" }, new[] { "" }, new[] { "" }, "", "", "", "", "", "");

            Product product = (Product)((JsonResult)(result)).Data;

            // delete product supplier
            //repository.DeleteProductSuppliers(owner);

            // delete product
            repository.DeleteProduct(product.id.Value, 0);

            // delete stock unit
            repository.DeleteStockUnits(owner);

            // delete test user
            TestUtils.deleteTestMember();
        }
Exemple #4
0
 public void TestMethod1()
 {
     var cont = new productsController();
 }