Пример #1
0
        // No ComplexNetworkOvertakeTest with test_overtake2.fpl as overtaking can only happen on the same route.

        private static void GeneralTrapezTest(Stream s)
        {
            var tt = new XMLImport().Import(s, new DummyPluginInterface());

            var analyzer = new IntersectionAnalyzer(tt);

            var station = tt.Stations.Single(st => st.SName == "B");

            // Normal
            {
                var probeTrain = tt.Trains.Single(t => t.TName == "P-normal");
                var trapez0    = analyzer.TrapezAtStation(probeTrain, station);
                Assert.AreEqual(0, trapez0.IntersectingTrainsStopping.Length);
                Assert.IsTrue(trapez0.IsStopping);
                Assert.AreEqual(Days.Parse("1111100"), trapez0.StopDays);
            }
            // Normal (reverse)
            {
                var probeTrain = tt.Trains.Single(t => t.TName == "C-normal");
                var trapez1    = analyzer.TrapezAtStation(probeTrain, station);

                Assert.AreEqual(1, trapez1.IntersectingTrainsStopping.Length);
                Assert.AreEqual("P-normal", trapez1.IntersectingTrainsStopping[0].TName);
                Assert.IsFalse(trapez1.IsStopping);
                Assert.AreEqual(Days.Parse("1111100"), trapez1.StopDays);
            }

            // Single train
            {
                var probeTrain = tt.Trains.Single(t => t.TName == "P-single");
                var trapez0    = analyzer.TrapezAtStation(probeTrain, station);
                Assert.AreEqual(0, trapez0.IntersectingTrainsStopping.Length);
                Assert.IsTrue(trapez0.IsStopping);
                Assert.AreEqual("1111100", trapez0.StopDays.ToBinString());
            }

            // Multiple
            {
                var probeTrain = tt.Trains.Single(t => t.TName == "P-multiple");
                var trapez0    = analyzer.TrapezAtStation(probeTrain, station);
                Assert.AreEqual(1, trapez0.IntersectingTrainsStopping.Length);
                Assert.AreEqual("C-multiple", trapez0.IntersectingTrainsStopping[0].TName);
                Assert.IsTrue(trapez0.IsStopping);
                Assert.AreEqual(Days.Parse("1111100"), trapez0.StopDays);

                var trapez1 = analyzer.TrapezAtStation(trapez0.IntersectingTrainsStopping[0], station);

                Assert.AreEqual(2, trapez1.IntersectingTrainsStopping.Length);
                Assert.AreEqual("P-multiple", trapez1.IntersectingTrainsStopping[0].TName);
                Assert.IsTrue(trapez1.IsStopping);
                Assert.AreEqual(Days.Parse("1111100"), trapez1.StopDays);
            }
        }
Пример #2
0
        public string TrapezHalt(ITrain probeTrain, Station s)
        {
            var trapez = analyzer.TrapezAtStation(probeTrain, s);

            if (trapez.IsStopping)
            {
                return("<span class=\"trapez-tt\">" + probeTrain.TName + "</span> " + DaysToStringNotEqual(probeTrain, trapez.StopDays));
            }
            if (trapez.IntersectingTrainsStopping.Any())
            {
                return(string.Join(", ", trapez.IntersectingTrainsStopping.Select(t => t.TName)) + " " + DaysToStringNotEqual(probeTrain, trapez.StopDays));
            }

            return("");
        }