public async void GetAllVehicles_WhenFound() { // arrange var locationId = IdentifierHelper.LocationId; var errorCodeConverter = new ErrorCodeConverter(); var locationServiceMoq = new Mock <ILocationService>(); locationServiceMoq.Setup(x => x.GetVehicles(It.IsAny <Guid>())) .ReturnsAsync(() => new Result <IEnumerable <Vehicle> >(ResultCode.Success, TestVehicles())); var dataStructureConverterMoq = new Mock <IDataStructureConverter>(); dataStructureConverterMoq.Setup(x => x.ConvertAndMap <IEnumerable <VehicleModel>, IEnumerable <Vehicle> >(It.IsAny <string>(), It.IsAny <IEnumerable <Vehicle> >())) .Returns(new Dictionary <string, object> { { "vehicles", VehicleHelper.GetMany() } }); var sut = new LocationsController(locationServiceMoq.Object, errorCodeConverter, dataStructureConverterMoq.Object) { ControllerContext = DefaultControllerContext() }; // act var result = await sut.GetAllVehicles(locationId); var okResult = result as OkObjectResult; var response = okResult.Value as Dictionary <string, object>; // assert Assert.Equal(200, okResult.StatusCode); }
private IEnumerable <Vehicle> TestVehicles() { return(VehicleHelper.GetMany()); }