public void Create_new_order_with_one_computer() { ComputersController computersController = new ComputersController(); ComputerInfoDto computerInfoDto = computersController.FindComputerByName("MacBook Pro 15"); int computerQuantity = 1; Decimal expectedPrice = computerInfoDto.Price; List <OrderInformationDto> orders = ordersController.All(); int previousNumberOfItems = orders.Count; NewOrderDto newOrderDto = new NewOrderDto { OrderLines = new List <NewOrderLineDto> { new NewOrderLineDto { ComputerId = computerInfoDto.Id, Quantity = computerQuantity } } }; NewOrderIdDto newOrderIdDto = ordersController.CreateNewOrder(newOrderDto); Assert.IsNotNull(newOrderIdDto); orders = ordersController.All(); OrderInformationDto order = ordersController.All().First(ord => ord.OrderId == newOrderIdDto.Id); Assert.AreEqual(previousNumberOfItems + 1, orders.Count); List <OrderLineInfoDto> newOrderOrderLinesInfo = order.OrderLinesInfo; Assert.AreEqual(1, newOrderOrderLinesInfo.Count); Assert.AreEqual(computerInfoDto.Id, newOrderOrderLinesInfo.First().ComputerId); Assert.AreEqual(computerQuantity, newOrderOrderLinesInfo.First().Quantity); Assert.AreEqual(expectedPrice, order.Price); }
public void Delete_existing_order() { ComputersController computersController = new ComputersController(); string macBookId = computersController.FindComputerByName("MacBook Pro 15").Id; string imacId = computersController.FindComputerByName("iMac 27").Id; NewOrderDto newOrderDto = new NewOrderDto { OrderLines = new List <NewOrderLineDto> { new NewOrderLineDto { ComputerId = macBookId, Quantity = 2 }, new NewOrderLineDto { ComputerId = imacId, Quantity = 2 } } }; OrdersController ordersController = new OrdersController("emilybeck", "password1"); NewOrderIdDto orderIdDto = ordersController.CreateNewOrder(newOrderDto); Assert.IsTrue(ordersController.All().Exists(order => order.OrderId.Equals(orderIdDto.Id))); _managementController.DeleteOrder(orderIdDto.Id); List <OrderInformationDto> allOrders = ordersController.All(); Assert.IsFalse(allOrders.Exists(order => order.OrderId.Equals(orderIdDto.Id))); }