public void returns_expected_result_when_valid(string value, AssociationCategory expectedResult) { var parser = BuildParser(); var result = parser.ParseProperty(value); Assert.AreEqual(expectedResult, result); }
public void HasConsistentLocationOnAssociated(string activities, AssociationCategory joinSplit, bool expected) { var stops = AssociationDictionaryTest.CreateAssociateStopsSettingClaphamActivities(joinSplit, activities); var schedule = TestSchedules.CreateScheduleWithService(stops: stops); var association = TestAssociations.CreateAssociation(category: joinSplit); Assert.Equal(expected, association.HasConsistentLocation(schedule, false)); }
public void MapCategory(string input, AssociationCategory expected) { var association = Test.Cif.TestAssociations.CreateAssociation(); association.Category = input; var output = MapAssociation(association); Assert.Equal(expected, output.Category); }
private Association CreateAssociation(AssociationCategory category, ScheduleLocation[] mainStops = null) { mainStops = mainStops ?? TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten); var main = TestSchedules.CreateScheduleWithService("X12345", retailServiceId: "VT123401", stops: mainStops).Service; var associated = TestSchedules.CreateScheduleWithService("A98765", retailServiceId: "VT123402", stops: TestSchedules.CreateClaphamWokingSchedule(TestSchedules.TenTwentyFive)).Service; var association = TestAssociations.CreateAssociationWithServices(main, associated, category: category); return(association); }
public void IsSplit(AssociationCategory category, bool expected) { var association = TestAssociations.CreateAssociationWithServices(category: category); var resolved = new ResolvedAssociation( association, DateTime.Today, false, null); ; Assert.Equal(expected, resolved.IsSplit); }
public static Association CreateAssociationWithServices( CifService mainService = null, CifService associatedService = null, StpIndicator indicator = StpIndicator.Permanent, ICalendar calendar = null, Location location = null, AssociationCategory category = AssociationCategory.Join, AssociationDateIndicator dateIndicator = AssociationDateIndicator.Standard, string associatedUid = "A98765", string retailServiceId = "VT123402" ) { mainService = mainService ?? TestSchedules.CreateScheduleWithService("X12345").Service; associatedService = associatedService ?? TestSchedules.CreateScheduleWithService(associatedUid, retailServiceId: retailServiceId).Service; var association = CreateAssociation(mainService.TimetableUid, associatedService.TimetableUid, indicator, calendar, location, category, dateIndicator); mainService.AddAssociation(association, true); associatedService.AddAssociation(association, false); return(association); }
public static Association CreateAssociation( string mainUid = "X12345", string associatedUid = "A98765", StpIndicator indicator = StpIndicator.Permanent, ICalendar calendar = null, Location location = null, AssociationCategory category = AssociationCategory.Join, AssociationDateIndicator dateIndicator = AssociationDateIndicator.Standard) { location = location ?? TestLocations.CLPHMJN; var main = new AssociationService() { TimetableUid = mainUid, AtLocation = location, Sequence = 1, }; var associated = new AssociationService() { TimetableUid = associatedUid, AtLocation = location, Sequence = 1, }; var association = new Association(Substitute.For <ILogger>()) { Main = main, Associated = associated, AtLocation = location, StpIndicator = indicator, Category = category, DateIndicator = dateIndicator, Calendar = calendar ?? TestSchedules.EverydayAugust2019 }; return(association); }
public static bool IsSplit(this AssociationCategory category) => category == AssociationCategory.Split;
public static bool IsJoin(this AssociationCategory category) => category == AssociationCategory.Join;
public void IsAssociatedConsistent(string activity, AssociationCategory category, bool expected) { var scheduleLocation = TestScheduleLocations.CreateStop(TestStations.Surbiton, Test, activity); Assert.Equal(expected, scheduleLocation.IsAssociatedConsistent(category)); }
public void IsSplit(AssociationCategory category, bool expected) { Assert.Equal(expected, category.IsSplit()); }
internal bool IsAssociatedConsistent(AssociationCategory category) => category.IsJoin() ? Activities.IsDestination : category.IsSplit() && Activities.IsOrigin;
internal bool IsMainConsistent(AssociationCategory category) => category.IsJoin() ? Activities.IsTrainJoin : category.IsSplit() && Activities.IsTrainSplit;
public static ScheduleLocation[] CreateAssociateStopsSettingClaphamActivities(AssociationCategory joinSplit, string activities) { ScheduleLocation[] stops; if (joinSplit.IsJoin()) { stops = TestSchedules.CreateWokingClaphamSchedule(TestSchedules.NineForty); stops[2].Activities = new Activities(activities); } else { stops = TestSchedules.CreateClaphamWokingSchedule(TestSchedules.TenTwentyFive); stops[0].Activities = new Activities(activities); } return(stops); }
public void AddSameAssociationWithDifferentLocationsResolveToCorrectForAssociated(string activities, AssociationCategory joinSplit, bool expectedHasAssociation) { Test(TestLocations.CLPHMJN, TestLocations.Woking); Test(TestLocations.Woking, TestLocations.CLPHMJN); void Test(Location location1, Location location2) { var stops = CreateAssociateStopsSettingClaphamActivities(joinSplit, activities); var service = TestSchedules.CreateScheduleWithService("A12345", stops: stops).Service; var association1 = TestAssociations.CreateAssociation(mainUid: "A67890", associatedUid: "A12345", category: joinSplit, location: location1); var association2 = TestAssociations.CreateAssociation(mainUid: "A67890", associatedUid: "A12345", category: joinSplit, location: location2); service.AddAssociation(association1, false); service.AddAssociation(association2, false); Assert.Equal(expectedHasAssociation, service.HasAssociations()); if (expectedHasAssociation) { var associations = service.GetAssociations()["A67890"]; Assert.Single(associations); Assert.Equal(TestLocations.CLPHMJN, associations.Single().Value.AtLocation); } } }