public void RemovedCancelledAssocation() { ResolvedService service = TestSchedules.CreateServiceWithAssociation(associationIsCancelled: true); Assert.True(service.HasAssociations()); var notCancelled = FilterCancelled(new [] { service }); Assert.NotEmpty(notCancelled); Assert.False(notCancelled[0].HasAssociations()); }
public void RemovedBrokenAssocation() { var service = TestSchedules.CreateServiceWithAssociation(); Assert.True(service.HasAssociations()); service.Associations[0].AsDynamic().Stop = null; var notBroken = FilterBroken(new [] { service }); Assert.False(notBroken[0].HasAssociations()); }
public void MapAssociation() { var mapper = ToViewProfileConfiguration.CreateMapper(); var resolved = TestSchedules.CreateServiceWithAssociation(); var find = new StopSpecification(TestStations.Surbiton, TestSchedules.Ten, TestDate, TimesToUse.Departures); resolved.TryFindStop(find, out var stop); var item = mapper.Map <Timetable.ResolvedServiceStop, Model.FoundSummaryItem>(stop, opts => opts.Items["On"] = stop.On); Assert.NotEmpty(item.Service.Associations); Assert.False(item.Association.IsIncluded); }
public void DeduplicateAlsoRemovesBrokenAssociations() { var service1 = TestSchedules.CreateServiceWithAssociation(); Assert.True(service1.HasAssociations()); service1.Associations[0].AsDynamic().Stop = null; var service2 = TestSchedules.CreateService("Z98765"); var filters = CreateFilter(); var filtered = filters.Deduplicate(new [] { service1, service2 }); Assert.False(service1.HasAssociations()); }
public void BrokenAssociationsNotRemovedIfReturningDebugResponses() { var service1 = TestSchedules.CreateServiceWithAssociation(); Assert.True(service1.HasAssociations()); service1.Associations[0].AsDynamic().Stop = null; var service2 = TestSchedules.CreateService("Z98765"); var filters = new ServiceFilters(true, Substitute.For <ILogger>()); var filtered = filters.RemoveBrokenServices(new [] { service1, service2 }); Assert.True(service1.HasAssociations()); }
public void BrokenAssociationsNotRemovedFromStopsIfReturningDebugResponses() { var service1 = TestSchedules.CreateServiceWithAssociation(); var stop1 = TestSchedules.CreateResolvedDepartureStop(service1); Assert.True(stop1.Service.HasAssociations()); service1.Associations[0].AsDynamic().Stop = null; var service2 = TestSchedules.CreateService("Z98765"); var stop2 = TestSchedules.CreateResolvedDepartureStop(service2); var filters = new ServiceFilters(true, Substitute.For <ILogger>()); var filtered = filters.Filter(new [] { stop1, stop2 }, true); Assert.True(stop1.Service.HasAssociations()); }
public void FilterStopsAlsoRemovesBrokenAssociations() { var service1 = TestSchedules.CreateServiceWithAssociation(); var stop1 = TestSchedules.CreateResolvedDepartureStop(service1); Assert.True(stop1.Service.HasAssociations()); service1.Associations[0].AsDynamic().Stop = null; var service2 = TestSchedules.CreateService("Z98765"); var stop2 = TestSchedules.CreateResolvedDepartureStop(service2); var filters = CreateFilter(); var filtered = filters.Filter(new [] { stop1, stop2 }, true); Assert.False(stop1.Service.HasAssociations()); }