private static VehicleMonitoringService GetReadyService()
        {
            var pingTimeout = TimeSpan.FromMilliseconds(50);
            var repoMock    = new Mock <IVehiclesRepository>();

            repoMock.Setup(repo => repo.GetAll()).Returns(() => Task.FromResult(TestData.GetVehicles()));

            var vehicleMonitoringService = new VehicleMonitoringService(repoMock.Object, pingTimeout);

            vehicleMonitoringService.Init().Wait();

            return(vehicleMonitoringService);
        }
        public async Task TestVehicleGetsConnectedAfterPing()
        {
            var vehiclesDataIntoDB = TestData.GetVehicles();

            using (var dbContext = new MssqlContext())
            {
                dbContext.Vehicles.AddRange(vehiclesDataIntoDB);
                await dbContext.SaveChangesAsync();
            }

            var vehicleMonitoringService = new VehicleMonitoringService(new VehiclesRepository(), TimeSpan.FromMilliseconds(50));
            await vehicleMonitoringService.Init();

            var apiController = new VehiclesStatusController(vehicleMonitoringService);

            var vehiclesStatusInfo = await apiController.Monitoring();

            Assert.IsTrue(vehiclesStatusInfo.Count() == vehiclesDataIntoDB.Count(), "Count of vehicles in db and returned from api does not match");
        }
 public VehiclesStatusController(VehicleMonitoringService vehicleService)
 {
     _vehicleService = vehicleService;
 }