Beispiel #1
0
        public async Task GetCurrentLocation_WithVehicleIdExists_ReturnStatusCodeOK()
        {
            // Arrange
            var vehicleId  = 1;
            var locationId = new Guid("CFB31112-C780-4535-815A-BB0C93EDD249");

            var vehicleResponse = new LocationResponse
            {
                Id        = locationId,
                VehicleId = 1,
                Latitude  = 13.788571,
                Longitude = 100.538034,
            };

            locationsService.GetCurrentLocationByVehicleIdAsync(Arg.Any <int>()).Returns(Task.FromResult(vehicleResponse));

            // Act
            var actionResult = await locationsController.GetCurrentLocationByVehicleId(vehicleId);

            var objectResult = actionResult as OkObjectResult;

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

            Assert.NotNull(response);
            Assert.Equal((int)System.Net.HttpStatusCode.OK, objectResult.StatusCode);
            Assert.Equal(locationId, response.Id);
            Assert.Equal(1, response.VehicleId);
            Assert.Equal(13.788571, response.Latitude);
            Assert.Equal(100.538034, response.Longitude);
        }