public async Task Call_VehicleSummaryService_with_given_make()
        {
            var make = "First";


            A.CallTo(() => _fakeVehicleSummaryService.GetSummaryByMake(make))
            .Returns(new VehicleSummaryResponse());


            var response = await _sut.Makes(make);


            A.CallTo(() => _fakeVehicleSummaryService.GetSummaryByMake(make))
            .MustHaveHappened();
        }
        public async Task <IActionResult> Make(string make)
        {
            _logger.LogInformation($"Received request to retrieve vehicle summary for vehicle make {make}");
            var response = await _vehicleSummaryService.GetSummaryByMake(make);

            _logger.LogInformation($"Returning vehicle summary response for vehicle make {make}: {JsonConvert.SerializeObject(response)}");
            return(Ok(response));
        }
        public async Task Task_GetVehicleSummaryMake_Return_OkResult()
        {
            var make = "Lotus";
            VehicleSummaryResponse mockVehicleSummaryResponse = new VehicleSummaryResponse();

            mockVehicleSummaryResponse.Make = "Lotus";
            VehicleSummaryModels vehicelSummaryModel = new VehicleSummaryModels();

            int[] years = new[] { 1990, 2000 };
            vehicelSummaryModel.Years.Add("1990");
            vehicelSummaryModel.Years.Add("2003");
            mockVehicleSummaryResponse.Models.Add(vehicelSummaryModel);

            A.CallTo(() => mockVehicleSummaryService.GetSummaryByMake(make))
            .Returns(mockVehicleSummaryResponse);


            var response = await controller.GetVehicleMake(make);

            A.CallTo(() => mockVehicleSummaryService.GetSummaryByMake(make)).Returns(mockVehicleSummaryResponse);
        }
示例#4
0
        public async Task Call_VehicleSummaryService_with_given_make()
        {
            // Arrange
            var make = "First";

            A.CallTo(() => _fakeVehicleSummaryService.GetSummaryByMake(make))
            .Returns(new VehicleSummaryResponse()
            {
                Make = make
            });

            // Act
            var response = await _sut.Make(make);

            // Assert
            A.CallTo(() => _fakeVehicleSummaryService.GetSummaryByMake(make))
            .MustHaveHappened();

            var okResult    = Assert.IsType <OkObjectResult>(response);
            var returnValue = Assert.IsType <VehicleSummaryResponse>(okResult.Value);

            Assert.Equal(returnValue.Make, make);
        }
        public async Task <IActionResult> GetVehicleMake(string make)
        {
            try
            {
                var response = await _vehicleSummaryService.GetSummaryByMake(make);

                return(Ok(response));
            } catch (FlurlHttpException ex)
            {
                HttpStatusCode httpStatusCode = (HttpStatusCode)ex.Call.HttpStatus;
                if (httpStatusCode == HttpStatusCode.NotFound)
                {
                    return(NotFound());
                }
                else if (httpStatusCode == HttpStatusCode.Forbidden)
                {
                    return(Forbid());
                }
                else
                {
                    return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
                }
            }
        }
示例#6
0
        public async Task <IActionResult> Makes(string make)
        {
            var response = await _vehicleSummaryService.GetSummaryByMake(make);

            return(Ok(make));
        }