public async void PutReturnValidResponseIfDeliveryNotFoundDueToIdMismatchTest() { var controller = new DeliveryController(deliveryService, mapper);; var response = await controller.Put(5, new UpdateDeliveryViewModel() { Id = 4 }); var notFoundResult = response as NotFoundObjectResult; Assert.NotNull(notFoundResult); Assert.Equal(404, notFoundResult.StatusCode); }
public async void PutReturnValidResponseIfDeliveryNotFoundTest() { var controller = new DeliveryController(deliveryService, mapper);; var response = await controller.Put(-5, new UpdateDeliveryViewModel() { Id = -5, StartTime = DateTime.Now.AddDays(2).AddHours(7), EndTime = DateTime.Now.AddDays(2).AddHours(10), }); var notFoundResult = response as NotFoundObjectResult; Assert.NotNull(notFoundResult); Assert.Equal(404, notFoundResult.StatusCode); }
public async void PutCannotAddDeliveryForForExpiredEndTimeTest() { var controller = new DeliveryController(deliveryService, mapper);; var model = new UpdateDeliveryViewModel() { Id = 1, StartTime = DateTime.Now, EndTime = DateTime.Now.AddHours(-5) }; var response = await controller.Put(1, model); var okResult = response as BadRequestObjectResult; Assert.NotNull(okResult); Assert.Equal(400, okResult.StatusCode); Assert.NotNull(okResult.Value); }
public async void PutTest() { var controller = new DeliveryController(deliveryService, mapper);; var model = new UpdateDeliveryViewModel() { Id = 1, Status = DeliveryStatus.Approved, StartTime = DateTime.Now.AddDays(2).AddHours(7), EndTime = DateTime.Now.AddDays(2).AddHours(10), }; var response = await controller.Put(1, model); var okResult = response as OkObjectResult; Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); Assert.NotNull(okResult.Value); var delivery = okResult.Value as DeliveryViewModel; Assert.Equal(Enum.GetName(typeof(DeliveryStatus), model.Status), delivery.Status); }