public async Task GetVehicle_ByVehicleId_ReturnStatusCodeOK()
        {
            // Arrange
            var vehicleId = 1;

            var vehicleResponse = new VehicleResponse
            {
                Id          = Guid.NewGuid(),
                VehicleId   = 1,
                Number      = "A-001",
                Model       = "Honda City",
                Description = "Blue Color"
            };

            vehiclesService.GetVehicleAsync(vehicleId).Returns(Task.FromResult(vehicleResponse));

            // Act
            var actionResult = await vehiclesController.GetVehicleById(vehicleId);

            var objectResult = actionResult as OkObjectResult;

            // Assert
            var response = objectResult.Value as VehicleResponse;

            Assert.NotNull(objectResult);
            Assert.Equal(vehicleId, response.VehicleId);
            Assert.Equal((int)System.Net.HttpStatusCode.OK, objectResult.StatusCode);
        }
        public async Task <IActionResult> GetVehicleById(int vehicleId)
        {
            var response = await vehiclesService.GetVehicleAsync(vehicleId);

            if (response == null)
            {
                return(NotFound());
            }

            return(Ok(response));
        }
Пример #3
0
        public async Task GetVehiclesList()
        {
            IsBusy = true;
            if (!(Connectivity.NetworkAccess == NetworkAccess.Internet))
            {
                await AlertService.DisplayAlertAsync("Error", "No internet connection, try later.", "Ok");
            }
            else
            {
                var getvehicles = await _vehiclesService.GetVehicleAsync();

                VehiclesCollection = getvehicles.ResultsVehicles;
            }
            IsBusy = false;
        }