private void InsertBreakBetween(string stationA, string stationB)
        {
            int aId = sd.GetKey(stationA);
            int bId = sd.GetKey(stationB);

            if (aId == -1)
            {
                throw new ArgumentException(stationA + " is misspelt");
            }

            if (bId == -1)
            {
                throw new ArgumentException(stationB + " is misspelt");
            }

            var children = MetroNetwork.GenChildrenFromStationId(aId);

            for (int i = 0; i < children.Count(); i++)
            {
                if (children[i].StationId == bId)
                {
                    MetroNetwork.InsertBreakBetween(aId, children[i]);
                    break;
                }
            }
        }
        public void InsertBreakTest()
        {
            int parentId = sd.GetKey("lancaster gate");
            var children = MetroNetwork.GenChildrenFromStationId(parentId);

            Assert.IsTrue(CheckContains(children, "queensway"));
            InsertBreakBetween("lancaster gate", "queensway");
            children = MetroNetwork.GenChildrenFromStationId(parentId);
            Assert.IsFalse(CheckContains(children, "queensway"));
        }
        public void GenChildrenFromIdTest()
        {
            var        children    = MetroNetwork.GenChildrenFromStationId(sd.GetKey("hammersmith"));
            List <int> childrenIds = new List <int>();

            childrenIds.Add(sd.GetKey("Goldhawk Road"));
            childrenIds.Add(sd.GetKey("Barons Court"));
            childrenIds.Add(sd.GetKey("Ravenscourt Park"));
            childrenIds.Add(sd.GetKey("Turnham Green"));

            foreach (var child in children)
            {
                Assert.IsTrue(childrenIds.Contains(child.StationId));
            }
        }
Exemplo n.º 4
0
        // editing methods

        public List <string> GetNeighbourNames(int parentId)
        {
            Children.Clear();
            this.ParentId = parentId;
            List <string> neighbours = new List <string>();

            Children = MetroNetwork.GenChildrenFromStationId(this.ParentId);
            string val;

            foreach (var child in Children)
            {
                val = LineDiction.GetValue(child.LineIndex) + ": " + StationDiction.GetValue(child.StationId);
                neighbours.Add(val);
            }

            return(neighbours);
        }