public async void CallTheAccidentStatisticsUrlFor2016()
            {
                var accidentStatistics = AutoFixture.CreateMany <AccidentStatistic>();

                HttpTest.RespondWithJson(accidentStatistics, 200);

                await TransportForLondonClient.GetAllAccidentStatistics(2016);

                HttpTest.ShouldHaveCalled("https://fake-api.tfl.gov.uk/AccidentStats/2016");
            }
Exemplo n.º 2
0
        private async Task GenerateDataFromLiveFeed(AccidentStatisticDbContext context)
        {
            _logger.Debug("About to generate data from the TFL live feed");
            var configuration = Configuration.Create();
            var logger        = Logger.Create();
            ITransportForLondonClient transportForLondonClient = new TransportForLondonClient(configuration, logger);
            var lastYear  = configuration.MaximumYear;
            var firstYear = 2005;

            if (IsTestDatabase(context))
            {
                firstYear = 2017;
            }
            for (int year = lastYear; year >= firstYear; year--)
            {
                try
                {
                    _logger.Information($"Getting data for year '{year}'");
                    Stopwatch stopwatch          = Stopwatch.StartNew();
                    var       accidentStatistics =
                        await transportForLondonClient.GetAllAccidentStatistics(year).ConfigureAwait(false);

                    stopwatch.Stop();
                    _logger.Debug($"Took '{stopwatch.Elapsed.ToString()}' to retrieve data for year '{year}'");
                    stopwatch = Stopwatch.StartNew();
                    await GeneraDataFor(context, accidentStatistics);

                    stopwatch.Stop();
                    _logger.Debug($"Took '{stopwatch.Elapsed.ToString()}' to insert data for year '{year}' into the local database");
                }
                catch (Exception e)
                {
                    Trace.TraceError($"Failed to get data for year '{year}'", e.Message, e.InnerException?.Message);
                }
            }
        }
Exemplo n.º 3
0
        public async void GetAccidentStatisticsFor2017()
        {
            var actual = await transportForLondonClient.GetAllAccidentStatistics(2017);

            actual.Should().NotBeNullOrEmpty();
        }