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