Exemplo n.º 1
0
        public void readTokenAtEntryTestInvalidId()
        {
            var reader = new DigitalReader("Bus", "Victoria");

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

            Assert.AreEqual(true, reader.readTokenAtEntry(sc.getID()));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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"));
        }
Exemplo n.º 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"));
        }
Exemplo n.º 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"));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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");
            }
        }
Exemplo n.º 9
0
        public void readTokenAtEntryTestInsufficientFunds()
        {
            var reader = new DigitalReader("Bus", "Victoria");

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