Пример #1
0
        private void LoadData()
        {
            List <ProductView> list = driver.GetAllProducts();

            dataGridView.DataSource = list;
            ConfigureDataGrid();
        }
Пример #2
0
        public void TestGetAllProducts()
        {
            ProductLogic logic = new ProductLogic();

            try
            {
                logic.Create(new ProductBinding {
                    Name = "Test1", Price = 10
                });
                logic.Create(new ProductBinding {
                    Name = "Test2", Price = 15
                });

                ProductsPageDriver driver = new ProductsPageDriver(new UiContext(new OrderLogic(), logic));

                List <ProductView> list = driver.GetAllProducts();

                Assert.Equal(2, list.Count);
                Assert.Equal("Test1", list[0].Name);
                Assert.Equal(10, list[0].Price);
                Assert.Equal("Test2", list[1].Name);
                Assert.Equal(15, list[1].Price);
            }
            finally
            {
                logic.Delete(null);
            }
        }
Пример #3
0
        public void TestGetAllProductsEmpty()
        {
            ProductsPageDriver driver = new ProductsPageDriver(new UiContext(new OrderLogic(), new ProductLogic()));

            List <ProductView> list = driver.GetAllProducts();

            Assert.Empty(list);
        }
Пример #4
0
        public void TestMethodDeleteProduct()
        {
            string       message = "";
            ProductLogic logic   = new ProductLogic();

            try
            {
                logic.Create(new ProductBinding {
                    Name = "Test1", Price = 10
                });
                logic.Create(new ProductBinding {
                    Name = "Test2", Price = 15
                });
                logic.Create(new ProductBinding {
                    Name = "Test3", Price = 23
                });
                ProductsPageDriver driver = new ProductsPageDriver(new UiContext(new OrderLogic(), logic));
                List <ProductView> list   = driver.GetAllProducts();
                driver.SelectedProduct = () => list[1];
                driver.ShowInfoMessage = (msg) => { message = msg; };

                driver.DeleteProduct();
                list = driver.GetAllProducts();

                Assert.Equal(2, list.Count);
                Assert.Equal("Test1", list[0].Name);
                Assert.Equal(10, list[0].Price);
                Assert.Equal("Test3", list[1].Name);
                Assert.Equal(23, list[1].Price);
                Assert.Equal("Product №2 was deleted", message);
            }
            finally
            {
                logic.Delete(null);
            }
        }