示例#1
0
        public void AddStationStringDuplicate()
        {
            Subway       subway      = new Subway();
            const string stationName = "Charing Cross";

            subway.AddStation(stationName);
            subway.AddStation(stationName);
            Assert.Fail();
        }
示例#2
0
        public void HasConnectionFalseStringStringString()
        {
            Subway       subway   = new Subway();
            const string lineName = "Rock Island Line";
            const string station1 = "Station 1";

            subway.AddStation(station1);
            const string station2 = "Station 2";

            subway.AddStation(station2);
            subway.AddConnection(station1, station2, lineName);
            Assert.IsFalse(subway.HasConnection("x", station2, lineName));
        }
示例#3
0
        public void AddStationEmpty()
        {
            Subway subway = new Subway();

            subway.AddStation("   ");
            Assert.Fail();
        }
示例#4
0
        public void HasStationStringFalse()
        {
            Subway       subway      = new Subway();
            const string stationName = "Charing Cross";

            subway.AddStation(stationName);
            Assert.IsFalse(subway.HasStation("Bogosity"));
        }
示例#5
0
        public void HasStationStringTrue()
        {
            Subway       subway      = new Subway();
            const string stationName = "Charing Cross";

            subway.AddStation(stationName);
            Assert.IsTrue(subway.HasStation(stationName));
        }
示例#6
0
        public void AddConnectionsStringNullString()
        {
            Subway subway   = new Subway();
            string station1 = "s1";

            subway.AddStation(station1);
            subway.AddConnection(station1, null, "line");
            Assert.Fail();
        }
示例#7
0
        public void AddConnectionsNullStringString()
        {
            Subway subway   = new Subway();
            string station2 = "s2";

            subway.AddStation(station2);
            subway.AddConnection(null, station2, "line");
            Assert.Fail();
        }
示例#8
0
        public void AddConnectionNoStation2StringStringString()
        {
            Subway subway   = new Subway();
            string station1 = "s1";
            string station2 = "s2";

            subway.AddStation(station1);
            subway.AddConnection(station1, station2, "line");
            Assert.Fail();
        }
示例#9
0
        private void loadStations(Subway subway, StreamReader reader)
        {
            string currentLine = reader.ReadLine();

            while (currentLine.Length > 0)
            {
                subway.AddStation(currentLine);
                currentLine = reader.ReadLine();
            }
        }
示例#10
0
        public void AddConnectionStringStringString()
        {
            Subway       subway   = new Subway();
            const string lineName = "Rock Island Line";
            const string station1 = "Station 1";

            subway.AddStation(station1);
            const string station2 = "Station 2";

            subway.AddStation(station2);

            Assert.AreEqual(0, subway.GetConnections().Count);
            subway.AddConnection(station1, station2, lineName);
            Assert.AreEqual(2, subway.GetConnections().Count);
            ICollection <Connection> connections = subway.GetConnections();
            bool result1 = connections.Contains(new Connection(new Station(station1), new Station(station2), lineName));
            bool result2 = connections.Contains(new Connection(new Station(station2), new Station(station1), lineName));

            Assert.IsTrue(result1 && result2);
        }
示例#11
0
        public void AddStationString()
        {
            Subway subway = new Subway();

            Assert.AreEqual(0, subway.GetStations().Count);

            const string stationName = "Charing Cross";

            subway.AddStation(stationName);
            Assert.AreEqual(1, subway.GetStations().Count);
            Assert.IsTrue(subway.GetStations().Contains(new Station(stationName)));
        }
示例#12
0
        public void AddStationNull()
        {
            Subway subway = new Subway();

            subway.AddStation(null);
        }