Пример #1
0
        public async Task AddViaRulesToStations()
        {
            var data = new Timetable.Data()
            {
                Tocs      = new TocLookup(Substitute.For <ILogger>()),
                Locations = new Timetable.LocationData(
                    new[]
                {
                    TestLocations.Surbiton,
                    TestLocations.WaterlooMain,
                    TestLocations.WaterlooWindsor,
                    TestLocations.CLPHMJN,
                    TestLocations.CLPHMJC,
                    TestLocations.Woking,
                    TestLocations.Guildford
                }, Substitute.For <ILogger>(),
                    Timetable.Test.Data.Filters.Instance)
            };
            var loader = CreateLoader(darwin: MockDownloader);

            data = await loader.EnrichReferenceDataAsync(data, CancellationToken.None);

            data.Locations.TryGetStation("SUR", out Station surbiton);
            var rules = StationMapperTest.GetViaRules(surbiton);

            Assert.NotEmpty(rules);
        }
Пример #2
0
        public void IsLoadedSet(ILocationData locations, ITimetableLookup timetable, bool expeected)
        {
            var data = new Timetable.Data();

            data.Locations = locations;
            data.Timetable = timetable;
            Assert.Equal(expeected, data.IsLoaded);
        }
Пример #3
0
        private IDataLoader CreateDataLoader(ILogger logger, Timetable.Data data = null)
        {
            data = data ?? CreateDummyData(logger);
            var loader = Substitute.For <IDataLoader>();

            loader.LoadAsync(Arg.Any <CancellationToken>()).Returns(Task.FromResult(data));
            return(loader);
        }
Пример #4
0
        public async Task LoadEmptyRealtime()
        {
            var data   = new Timetable.Data();
            var loader = new NopLoader();

            data = await loader.EnrichReferenceDataAsync(data, CancellationToken.None);

            Assert.NotNull(data.Darwin);
            Assert.Empty(data.Darwin.CancelReasons);
            Assert.Empty(data.Darwin.LateRunningReasons);
            Assert.Empty(data.Darwin.Sources);
        }
Пример #5
0
        public async Task EnrichAddsTocs()
        {
            var data = new Timetable.Data()
            {
                Tocs      = new TocLookup(Substitute.For <ILogger>()),
                Locations = TestData.Locations
            };
            var loader = CreateLoader(darwin: MockDownloader);

            data = await loader.EnrichReferenceDataAsync(data, CancellationToken.None);

            Assert.NotEmpty(data.Tocs);
        }
Пример #6
0
        public async Task UpdateLocations()
        {
            var data = new Timetable.Data()
            {
                Tocs      = new TocLookup(Substitute.For <ILogger>()),
                Locations = TestData.Locations
            };
            var loader = CreateLoader(darwin: MockDownloader);

            data = await loader.EnrichReferenceDataAsync(data, CancellationToken.None);

            data.Locations.TryGetStation("WAT", out Station waterloo);
            Assert.Equal("London Waterloo", waterloo.Name);
        }
Пример #7
0
        public async Task StationsHaveViaTextFromDarwin()
        {
            var loader = CreateCifLoader();
            var data   = new Timetable.Data()
            {
                Tocs      = new TocLookup(Substitute.For <ILogger>()),
                Locations = await loader.LoadStationMasterListAsync(CancellationToken.None)
            };

            var darwinLoader = await CreateDarwinLoader();

            data = await darwinLoader.EnrichReferenceDataAsync(data, CancellationToken.None);

            var locations = data.Locations as LocationData;

            Assert.NotEmpty(locations.Locations.Values.Where(s => StationMapperTest.GetViaRules(s).Any()));
        }
Пример #8
0
        public async Task StationsHaveNamesFromDarwin()
        {
            var loader = CreateCifLoader();
            var data   = new Timetable.Data()
            {
                Tocs      = new TocLookup(Substitute.For <ILogger>()),
                Locations = await loader.LoadStationMasterListAsync(CancellationToken.None)
            };

            var darwinLoader = await CreateDarwinLoader();

            data = await darwinLoader.EnrichReferenceDataAsync(data, CancellationToken.None);

            var locations = data.Locations as LocationData;

            Assert.NotEmpty(locations.Locations.Values.Where(l => !string.IsNullOrEmpty(l.Name)));
        }
Пример #9
0
        public async Task LoadDarwinTocs()
        {
            var data = new Timetable.Data()
            {
                Tocs      = new TocLookup(Substitute.For <ILogger>()),
                Locations = new LocationData(
                    new List <Location>(),
                    Substitute.For <ILogger>(),
                    Timetable.Test.Data.Filters.Instance)
            };

            var loader = await CreateDarwinLoader();

            data = await loader.EnrichReferenceDataAsync(data, CancellationToken.None);

            Assert.NotEmpty(data.Tocs);
        }
Пример #10
0
        private Timetable.Data CreateDummyData(ILogger logger)
        {
            var filters = Timetable.Test.Data.Filters.Instance;

            var data = new Timetable.Data();

            data.Locations = new LocationData(new List <Location>(), logger, filters)
            {
                IsLoaded = true
            };
            data.Timetable = new TimetableData(filters, logger)
            {
                IsLoaded = true
            };
            data.Tocs = new TocLookup(logger);
            return(data);
        }