Beispiel #1
0
        public void readTokenAtEntryTestInvalidId()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            Assert.AreEqual(false, reader.readTokenAtEntry(-999999));
            Assert.AreEqual(false, reader.readTokenAtEntry(999999));
        }
Beispiel #2
0
        public void readTokenAtEntryTestBasicTrain()
        {
            sc.updateAccountBalance(10);
            var reader = new DigitalReader("Train", "Victoria");

            Assert.AreEqual(true, reader.readTokenAtEntry(sc.getID()));
        }
Beispiel #3
0
        public void readTokenAtExitTestDayPassMultipleTrips()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            sc.updateAccountBalance(50);
            float dpCost   = FareRules.Instance.getDayPassCost();
            float expected = sc.getAccount().getBalance() - dpCost;

            reader.setLocation(RailMap.Instance.getLocation("Edgware Road"));
            reader.readTokenAtEntry(sc.getID());
            reader.setLocation(RailMap.Instance.getLocation("Kings Cross"));
            reader.readTokenAtExit(sc.getID(), "Circle");

            reader.setLocation(RailMap.Instance.getLocation("Kings Cross"));
            reader.readTokenAtEntry(sc.getID());
            reader.setLocation(RailMap.Instance.getLocation("Victoria"));
            float actual = reader.readTokenAtExit(sc.getID(), "Circle");

            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
        public void readTokenAtExitTestSameStopNoCharge()
        {
            sc.updateAccountBalance(10);
            var reader = new DigitalReader("Train", "Victoria");

            reader.setLocation(RailMap.Instance.getLocation("Baker Street"));
            reader.readTokenAtEntry(sc.getID());
            float expectedBalance = ac.getBalance();

            Assert.AreEqual(expectedBalance, reader.readTokenAtExit(sc.getID(), "Circle"));
        }
Beispiel #5
0
        public void readTokenAtExitTestBasic()
        {
            sc.updateAccountBalance(10);
            var reader = new DigitalReader("Train", "Victoria");

            reader.setLocation(RailMap.Instance.getLocation("Baker Street"));
            reader.readTokenAtEntry(sc.getID());
            reader.setLocation(RailMap.Instance.getLocation("Great Portland Street"));
            float expectedBalance = ac.getBalance() - FareRules.Instance.getCostPerStation();

            Assert.AreEqual(expectedBalance, reader.readTokenAtExit(sc.getID(), "Circle"));
        }
Beispiel #6
0
        public void readTokenAtExitInsufficientFunds()
        {
            sc2.updateAccountBalance(5);
            var reader = new DigitalReader("Train", "Victoria");

            reader.setLocation(RailMap.Instance.getLocation("Baker Street"));
            reader.readTokenAtEntry(sc2.getID());
            reader.setLocation(RailMap.Instance.getLocation("Victoria"));
            float expectedResult = -1f;

            Assert.AreEqual(expectedResult, reader.readTokenAtExit(sc2.getID(), "Circle"));
        }
Beispiel #7
0
        public void readTokenAtExitTestMultipleLines()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            sc.updateAccountBalance(50);
            float expected = sc.getAccount().getBalance() - (FareRules.Instance.getCostPerStation() * 2);

            reader.setLocation(RailMap.Instance.getLocation("Westminster"));
            reader.readTokenAtEntry(sc.getID());
            reader.setLocation(RailMap.Instance.getLocation("Pimlico"));
            float actual = reader.readTokenAtExit(sc.getID(), "Victoria");

            Assert.AreEqual(expected, actual);
        }
Beispiel #8
0
        private void btnEnterGate_Click(object sender, EventArgs e)
        {
            DigitalReader currentReader = new DigitalReader("Bus", this.start);

            tokenId = (int)cbxTokens.SelectedValue;
            if (currentReader.readTokenAtEntry(tokenId))
            {
                MessageBox.Show("Gate Open");
                new frmRailTravelSim(start, tokenId).Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Invalid Entry Token/Insufficient Funds");
            }
        }
Beispiel #9
0
        public void readTokenAtEntryTestInsufficientFunds()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            Assert.AreEqual(false, reader.readTokenAtEntry(sc2.getID()));
        }