示例#1
0
        public void readTokenAtEntryTestBasicTrain()
        {
            sc.updateAccountBalance(10);
            var reader = new DigitalReader("Train", "Victoria");

            Assert.AreEqual(true, reader.readTokenAtEntry(sc.getID()));
        }
示例#2
0
        public void readTokenAtEntryTestInvalidId()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            Assert.AreEqual(false, reader.readTokenAtEntry(-999999));
            Assert.AreEqual(false, reader.readTokenAtEntry(999999));
        }
示例#3
0
        public void getReaderTypeTestBasic()
        {
            var reader        = new DigitalReader("Bus", "Victoria");
            var anotherReader = new DigitalReader("Train", "Victoria");

            Assert.AreEqual("Bus", reader.getReaderType());
            Assert.AreEqual("Train", anotherReader.getReaderType());
        }
示例#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"));
        }
示例#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"));
        }
示例#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"));
        }
示例#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);
        }
示例#8
0
        public void readTokenAtExitTestDayPassOneTrip()
        {
            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("Victoria"));
            float actual = reader.readTokenAtExit(sc.getID(), "Circle");

            Assert.AreEqual(expected, actual);
        }
示例#9
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");
            }
        }
示例#10
0
        private void btnExitGate_Click(object sender, EventArgs e)
        {
            float         currentBalance = 0;
            DigitalReader currentReader  = new DigitalReader("Bus", currentLocation);

            try
            {
                currentBalance = currentReader.readTokenAtExit(tokenId, currentLine);// to return float
                if (currentBalance < 0)
                {
                    MessageBox.Show("Invalid Token/Insufficient funds");
                }
                else if (currentBalance >= 0)
                {
                    MessageBox.Show("Remaining Balance: " + currentBalance);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#11
0
        public void readTokenAtExitTestAnotherInvalidId()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            reader.readTokenAtExit(999999, "Circle");
        }
示例#12
0
 public void digitalReaderConstructionTestInvalidType()
 {
     var reader = new DigitalReader("Waffle Iron", "Victoria");
 }
示例#13
0
        public void getDateTestBasic()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            Assert.AreEqual(DateTime.Now.ToString("yyyy-MM-dd"), reader.getDay().ToString("yyyy-MM-dd"));
        }
示例#14
0
        public void readTokenAtEntryTestInsufficientFunds()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            Assert.AreEqual(false, reader.readTokenAtEntry(sc2.getID()));
        }
示例#15
0
        public void readTokenAtExitTestNoEntryScan()
        {
            var reader = new DigitalReader("Train", "Victoria");

            reader.readTokenAtExit(sc.getID(), "Circle");
        }
示例#16
0
 public void digitalReaderConstructionTestAnotherInvalidType()
 {
     var reader = new DigitalReader("All of the bees", "Victoria");
 }
示例#17
0
 public void digitalReaderConstructionNullType()
 {
     var reader = new DigitalReader(null, "Victoria");
 }