public void Add_ClientOrderCorrectEntity_ReturnId() { // Arrange ClientOrderProvider clientOrderProvider = new ClientOrderProvider(); var allClientOrders = clientOrderProvider.GetAll().OrderByDescending(p => p.Id); ClientOrder lastClientOrder = allClientOrders.FirstOrDefault() ?? new ClientOrder(); ClientOrderHandler clientOrderHandler = new ClientOrderHandler(); ClientOrder clientOrder = new ClientOrder(); clientOrder.ClientId = "c983fea1-a550-4ea6-b45a-db66d9defcc1"; clientOrder.DeliveryId = 1; clientOrder.CreationDate = DateTime.Now; clientOrder.DeliveryDate = DateTime.Now; clientOrder.Orders = new List <Order>() { new Order() { ProductId = 1, Quantity = 1 } }; // Act int id = clientOrderHandler.Add(clientOrder); // Assert Assert.IsTrue(lastClientOrder.Id < id); }
public void Delete_ClientOrderExists_ReturnTrue() { // Arrange ClientOrderProvider clientOrderProvider = new ClientOrderProvider(); var allClientOrders = clientOrderProvider.GetAll().OrderByDescending(p => p.Id); ClientOrder lastClientOrder = allClientOrders.FirstOrDefault() ?? new ClientOrder(); ClientOrderHandler clientOrderHandler = new ClientOrderHandler(); // Act bool result = clientOrderHandler.Delete(lastClientOrder.Id); var deletedClientOrder = clientOrderProvider.GetById(lastClientOrder.Id); // Assert Assert.IsTrue(result); Assert.IsNull(deletedClientOrder); }