Esempio n. 1
0
        public async Task GetCurrentLocationByVehicleIdAsync_WithVehicleIdExists_ReturnLocationResponse()
        {
            // Arrange
            var vehicleId = 1;

            var location = new Location
            {
                Id         = Guid.NewGuid(),
                VehicleId  = 1,
                Latitude   = 13.788571,
                Longitude  = 100.538034,
                UpdateDate = new DateTime(2020, 3, 1)
            };

            locationsRepository.GetCurrentLocationByVehicleIdAsync(Arg.Any <int>()).Returns(Task.FromResult(location));

            // Act
            var response = await locationsService.GetCurrentLocationByVehicleIdAsync(vehicleId);

            // Assert
            Assert.NotNull(response);
            Assert.IsType <LocationResponse>(response);
            Assert.Equal(1, response.VehicleId);
            Assert.Equal(13.788571, response.Latitude);
            Assert.Equal(100.538034, response.Longitude);
        }