Esempio n. 1
0
        public async Task AddLocationAsync_WithLocationRequest_ReturnLocationResponse()
        {
            var locationRequest = new LocationRequest
            {
                VehicleId = 1,
                Latitude  = 13.788571,
                Longitude = 100.538034
            };

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

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

            vehiclesRepository.GetVehicleByVehicleIdAsync(Arg.Any <int>()).Returns(Task.FromResult(vehicle));
            locationsRepository.AddLocationAsync(Arg.Any <Location>()).Returns(Task.FromResult(location));

            // Act
            var response = await locationsService.AddLocationAsync(locationRequest);

            // 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);
        }