private static void GeneralOvertakeTest(Stream s) { var tt = new XMLImport().Import(s, new DummyPluginInterface()); var analyzer = new IntersectionAnalyzer(tt); var station = tt.Stations.Single(st => st.SName == "B"); // Overlap at end { var probeTrain = tt.Trains.Single(t => t.TName == "P-overlap-end"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-overlap-end", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Overlap at begin { var probeTrain = tt.Trains.Single(t => t.TName == "P-overlap-begin"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-overlap-begin", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Overlap in the middle { var probeTrain = tt.Trains.Single(t => t.TName == "P-overlap-middle"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-overlap-middle", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Second train with no stop time { var probeTrain = tt.Trains.Single(t => t.TName == "P-no-minutes"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-no-minutes", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Second train with no stop time (two trains) { var probeTrain = tt.Trains.Single(t => t.TName == "P-no-minutes-double"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(2, crossingWith.Length); Assert.AreEqual("C-no-minutes-double1", crossingWith[0].TName); Assert.AreEqual("C-no-minutes-double2", crossingWith[1].TName); } }
public string Ueberholt(ITrain ot, Station s) { return(string.Join(", ", analyzer.OvertakeAtStation(ot, s) .Select(tr => tr.TName + " " + IntersectDaysSt(ot, tr)))); }