[TestMethod] public void AddingSameStationTwiceThrows() { var target = new TrackLayout("Test"); var station = TestDataFactory.CreateStation1(); target.Add(station); target.Add(station); }
public static TrackLayout Layout() { var layout = new TrackLayout("Test"); foreach (var s in Stations) layout.Add(s); var timetableStretch = new TimetableStretch("1"); var ss = Stations.ToArray(); timetableStretch.Add(layout.Add(ss[0].Exit("Vänster"), ss[1].Exit("Höger"), 10)); timetableStretch.Add(layout.Add(ss[1].Exit("Vänster"), ss[2].Exit("Höger"), 10)); layout.Add(timetableStretch); return layout; }
static TrackLayout GetLayout() { var layout = new TrackLayout("Test"); var stations = TestDataFactory.Stations.ToArray(); foreach (var station in stations) { layout.Add(station); } layout.Add(stations[0].Exit("Vänster"), stations[1].Exit("Höger"), 10); layout.Add(stations[2].Exit("Höger"), stations[1].Exit("Vänster"), 10); return layout; }
private static TrackLayout GetTestLayout(string name) { var layout = new TrackLayout(name); var stations = TestDataFactory.Stations.ToArray(); foreach (var station in stations) { layout.Add(station); } layout.Add(stations[0].Exit("Vänster"), stations[1].Exit("Höger"), 10); layout.Add(stations[2].Exit("Höger"), stations[1].Exit("Vänster"), 10); return(layout); }
private static IEnumerable <Message> GetStations(TrackLayout layout, Excel.Workbook book) { var messages = new List <Message>(); Excel.Worksheet sheet = book.Worksheets["StationTrack"] as Excel.Worksheet; var r = 1; Station current = null; var loop = true; while (loop) { var row = (Array)(sheet.get_Range(Cell("A", r), Cell("G", r)).Cells.Value); var col1 = row.Value(1)?.ToString(); if (col1 == null) { break; } if (col1 != "Name") { var rowType = row.Value(6).ToUpperInvariant(); switch (rowType) { case "STATION": if (current != null) { layout.Add(current); } current = new Station(row.Value(5), row.Value(1)); break; case "TRACK": current.Add(new StationTrack(row.Value(3))); break; default: loop = false; break; } } r++; } if (current != null) { layout.Add(current); } return(messages); }
private static IEnumerable <Message> GetStretches(TrackLayout layout, Excel.Workbook book) { var messages = new List <Message>(); Excel.Worksheet sheet = book.Worksheets["Routes"] as Excel.Worksheet; for (var r = 2; ; r++) { var row = (Array)sheet.get_Range(Cell("A", r), Cell("I", r)).Cells.Value; if (row.GetValue(1, 1) == null) { break; } else { var timetableStretchNumber = row.Value(1); var tracksCount = int.Parse(row.Value(8), CultureInfo.InvariantCulture); var fromName = row.Value(3); var toName = row.Value(5); var distance = double.Parse(row.Value(9).Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture); var fromStation = layout.Station(fromName); if (fromStation.IsNone) { messages.Add(Message.Error(fromStation.Message)); continue; } var fromExit = new StationExit(toName); fromStation.Value.Add(fromExit); var toStation = layout.Station(toName); if (toStation.IsNone) { messages.Add(Message.Error(toStation.Message)); } else { var toExit = new StationExit(fromName); toStation.Value.Add(toExit); var addedStretch = layout.Add(fromExit, toExit, distance, tracksCount); if (!layout.HasTimetableStretch(timetableStretchNumber)) { layout.Add(new TimetableStretch(timetableStretchNumber)); } layout.TimetableStretch(timetableStretchNumber).Add(addedStretch); } } } return(messages); }
public static TrackLayout Layout() { var layout = new TrackLayout("Test"); foreach (var s in Stations) { layout.Add(s); } var timetableStretch = new TimetableStretch("1"); var ss = Stations.ToArray(); timetableStretch.Add(layout.Add(ss[0].Exit("Vänster"), ss[1].Exit("Höger"), 10)); timetableStretch.Add(layout.Add(ss[1].Exit("Vänster"), ss[2].Exit("Höger"), 10)); layout.Add(timetableStretch); return(layout); }