public async Task Get_WhenNoVehicleTypesAdded_ReturnsNoContentStatusCode() { _vehicleTypeService.Setup(s => s.GetAllVehicleTypes()).Returns(Task.FromResult(new List <VehicleType> { }.AsEnumerable())); VehicleTypeController controller = new VehicleTypeController(_vehicleTypeService.Object); IActionResult result = await controller.Get(); Assert.That(result, Is.InstanceOf(typeof(NoContentResult))); }
public async Task Get_WhenThereAreVehicleTypes_ReturnsOkStatusCode() { List <VehicleType> expectedResult = new List <VehicleType> { _vehicleType }; _vehicleTypeService.Setup(s => s.GetAllVehicleTypes()).Returns(Task.FromResult(expectedResult.AsEnumerable())); VehicleTypeController controller = new VehicleTypeController(_vehicleTypeService.Object); IActionResult result = await controller.Get(); var okResult = result as OkObjectResult; var resultValue = okResult.Value; Assert.That(result, Is.InstanceOf(typeof(OkObjectResult))); Assert.That(resultValue, Is.EqualTo(expectedResult)); }