public void Update_DeliveryCorrectEntity_ReturnTrueAndNewEntityHasCorrectSetFields() { // Arrange DeliveryProvider deliveryProvider = new DeliveryProvider(); var oldDeliverys = deliveryProvider.GetById(1); DeliveryHandler deliveryHandler = new DeliveryHandler(); Delivery delivery = new Delivery(); delivery.Id = 1; delivery.Name = "NEW_Name"; delivery.Price = 999.99m; // Act bool result = deliveryHandler.Update(delivery); var newDeliverys = deliveryProvider.GetById(1); // Assert Assert.IsTrue(result); Assert.AreEqual("NEW_Name", newDeliverys.Name); Assert.AreEqual(999.99m, newDeliverys.Price); }
public void Delete_DeliveryExists_ReturnTrue() { // Arrange DeliveryProvider deliveryProvider = new DeliveryProvider(); var allDeliverys = deliveryProvider.GetAll().OrderByDescending(p => p.Id); Delivery lastDelivery = allDeliverys.FirstOrDefault() ?? new Delivery(); DeliveryHandler deliveryHandler = new DeliveryHandler(); // Act bool result = deliveryHandler.Delete(lastDelivery.Id); var deletedDelivery = deliveryProvider.GetById(lastDelivery.Id); // Assert Assert.IsTrue(result); Assert.IsNull(deletedDelivery); }