private void LoadData() { List <ProductView> list = driver.GetAllProducts(); dataGridView.DataSource = list; ConfigureDataGrid(); }
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); } }
public void TestGetAllProductsEmpty() { ProductsPageDriver driver = new ProductsPageDriver(new UiContext(new OrderLogic(), new ProductLogic())); List <ProductView> list = driver.GetAllProducts(); Assert.Empty(list); }
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); } }