public void TestDeleteOrderProducts() { OrderLogic logicO = new OrderLogic(); ProductLogic logicP = new ProductLogic(); try { OrderBinding model1 = new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }; model1.OrderProducts.Add(new OrderProductBinding { ProductId = 1 }); logicP.Create(new ProductBinding()); logicO.Create(model1); logicO.Delete(model1); OrderBinding model2 = new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }; model2.OrderProducts.Add(new OrderProductBinding { ProductId = 1 }); logicO.Create(model2); List <OrderView> list = logicO.Read(null); Assert.Single(list[0].OrderProducts); } finally { logicO.Delete(null); logicP.Delete(null); } }
public void TestMethodDelete() { string message = ""; OrderLogic orderLogic = new OrderLogic(); OrdersPageDriver driver = new OrdersPageDriver(new UiContext(new OrderLogic(), new ProductLogic())); driver.ShowInfoMessage = (msg) => { message = msg; }; try { orderLogic.Create(new OrderBinding { OrderProducts = new List <OrderProductBinding>() }); orderLogic.Create(new OrderBinding { OrderProducts = new List <OrderProductBinding>() }); orderLogic.Create(new OrderBinding { OrderProducts = new List <OrderProductBinding>() }); driver.SelectedOrder = () => orderLogic.Read(null)[1]; driver.DeleteOrder(); List <OrderView> list = driver.GetAllOrders(); Assert.Equal(2, list.Count); Assert.Equal(1, list[0].Id); Assert.Equal(3, list[1].Id); Assert.Equal("Order №2 was deleted", message); } finally { orderLogic.Delete(null); } }
public void TestDeleteSingle() { OrderLogic logic = new OrderLogic(); try { OrderBinding model1 = new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }; OrderBinding model2 = new OrderBinding { Id = 2, OrderProducts = new List <OrderProductBinding>() }; logic.Create(model1); logic.Create(model2); logic.Delete(model1); List <OrderView> list = logic.Read(null); Assert.Single(list); Assert.Equal(2, list[0].Id); } finally { logic.Delete(null); } }
public void TestMethodSaveUpdatedOrder() { string message = ""; OrderLogic logicO = new OrderLogic(); ProductLogic logicP = new ProductLogic(); try { logicP.Create(new ProductBinding { Price = 10 }); logicO.Create(new OrderBinding()); OrderPageDriver driver = new OrderPageDriver(new UiContext(logicO, logicP), logicO.Read(null)[0]); driver.ShowInfoMessage = (msg) => { message = msg; }; driver.MoveToOrderProductPage = (context, order, orderProduct) => order.OrderProducts.Add(new OrderProductView { ProductId = 1 }); driver.AddOrderProduct(); driver.AddOrderProduct(); driver.AddOrderProduct(); bool result = driver.SaveOrder(); List <OrderView> list = logicO.Read(null); Assert.True(result); Assert.Single(list); Assert.Single(list[0].OrderProducts); Assert.Equal("Order №1 was updated", message); } finally { logicO.Delete(null); logicP.Delete(null); } }
public void TestOrderProductPrice() { OrderLogic logicO = new OrderLogic(); ProductLogic logicP = new ProductLogic(); try { ProductBinding product = new ProductBinding { Name = "Test", Price = 20 }; OrderBinding order = new OrderBinding { OrderProducts = new List <OrderProductBinding>() }; order.OrderProducts.Add(new OrderProductBinding { ProductId = 1, Count = 2 }); logicP.Create(product); logicO.Create(order); List <OrderView> list = logicO.Read(null); Assert.Equal(20, list[0].OrderProducts[0].Price); } finally { logicO.Delete(null); logicP.Delete(null); } }
public void TestCreateWithOrderProducts() { OrderLogic logicO = new OrderLogic(); ProductLogic logicP = new ProductLogic(); try { OrderBinding model = new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }; model.OrderProducts.Add(new OrderProductBinding { Count = 10, ProductId = 1 }); model.OrderProducts.Add(new OrderProductBinding { Count = 13, ProductId = 2 }); logicP.Create(new ProductBinding { Id = 1, Name = "0", Price = 10 }); logicP.Create(new ProductBinding { Id = 2, Name = "1", Price = 5 }); logicO.Create(model); List <OrderView> list = logicO.Read(null); Assert.Equal(2, list[0].OrderProducts.Count); Assert.Equal(5, list[0].OrderProducts[1].Price); } finally { logicO.Delete(null); logicP.Delete(null); } }
public void TestCreateSeveralOPWithSameProductId() { OrderLogic logicO = new OrderLogic(); ProductLogic logicP = new ProductLogic(); try { OrderBinding model = new OrderBinding { OrderProducts = new List <OrderProductBinding>() }; model.OrderProducts.Add(new OrderProductBinding { ProductId = 1, Count = 3 }); model.OrderProducts.Add(new OrderProductBinding { ProductId = 1, Count = 2 }); logicP.Create(new ProductBinding { Id = 1 }); logicO.Create(model); List <OrderView> list = logicO.Read(null); Assert.Single(list[0].OrderProducts); Assert.Equal(1, list[0].OrderProducts[0].ProductId); Assert.Equal(5, list[0].OrderProducts[0].Count); } finally { logicO.Delete(null); logicP.Delete(null); } }
public void TestOrderProductAutoId() { OrderLogic logicO = new OrderLogic(); ProductLogic logicP = new ProductLogic(); try { OrderBinding model1 = new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }; OrderBinding model2 = new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }; model1.OrderProducts.Add(new OrderProductBinding { ProductId = 1 }); model1.OrderProducts.Add(new OrderProductBinding { ProductId = 2 }); model2.OrderProducts.Add(new OrderProductBinding { ProductId = 1 }); logicP.Create(new ProductBinding { Name = "0" }); logicP.Create(new ProductBinding { Name = "1" }); logicO.Create(model1); logicO.Create(model2); List <OrderView> list = logicO.Read(null); Assert.Equal(1, list[0].OrderProducts[0].Id); Assert.Equal(2, list[0].OrderProducts[1].Id); Assert.Equal(3, list[1].OrderProducts[0].Id); Assert.Equal(1, list[0].OrderProducts[0].OrderId); Assert.Equal(1, list[0].OrderProducts[1].OrderId); Assert.Equal(2, list[1].OrderProducts[0].OrderId); } finally { logicO.Delete(null); logicP.Delete(null); } }
public void TestUpdateSeveralOPWithSameProductId() { OrderLogic logicO = new OrderLogic(); ProductLogic logicP = new ProductLogic(); try { logicP.Create(new ProductBinding { Name = "0" }); logicP.Create(new ProductBinding { Name = "1" }); OrderBinding model = new OrderBinding { OrderProducts = new List <OrderProductBinding>() }; model.OrderProducts.Add(new OrderProductBinding { ProductId = 1, Count = 3 }); logicO.Create(model); OrderView ov = logicO.Read(null)[0]; OrderBinding model2 = new OrderBinding { Id = ov.Id, OrderProducts = new List <OrderProductBinding>() }; model2.OrderProducts.Add(new OrderProductBinding { ProductId = 1, Count = 3 }); model2.OrderProducts.Add(new OrderProductBinding { ProductId = 1, Count = 2 }); model2.OrderProducts.Add(new OrderProductBinding { ProductId = 2, Count = 1 }); model2.OrderProducts.Add(new OrderProductBinding { ProductId = 2, Count = 5 }); logicO.Update(model2); List <OrderView> list = logicO.Read(null); Assert.Equal(2, list[0].OrderProducts.Count); Assert.Equal(1, list[0].OrderProducts[0].ProductId); Assert.Equal(5, list[0].OrderProducts[0].Count); Assert.Equal(2, list[0].OrderProducts[1].ProductId); Assert.Equal(6, list[0].OrderProducts[1].Count); } finally { logicO.Delete(null); logicP.Delete(null); } }
public void TestOrdersListNotEmpty() { OrderLogic orderLogic = new OrderLogic(); OrdersPageDriver driver = new OrdersPageDriver(new UiContext(orderLogic, new ProductLogic())); try { orderLogic.Create(new OrderBinding { OrderProducts = new List <OrderProductBinding>() }); orderLogic.Create(new OrderBinding { OrderProducts = new List <OrderProductBinding>() }); List <OrderView> list = driver.GetAllOrders(); Assert.Equal(2, list.Count); } finally { orderLogic.Delete(null); } }
public void TestDeleteAll() { OrderLogic logic = new OrderLogic(); OrderBinding model = new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }; logic.Create(model); logic.Delete(null); List <OrderView> list = logic.Read(null); Assert.Empty(list); }
public void TestCreate() { OrderLogic logic = new OrderLogic(); try { logic.Create(new OrderBinding { Id = 1, OrderProducts = new List <OrderProductBinding>() }); List <OrderView> list = logic.Read(null); Assert.Single(list); Assert.Equal(1, list[0].Id); } finally { logic.Delete(null); } }