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

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

            Assert.AreEqual(false, reader.readTokenAtEntry(-999999));
            Assert.AreEqual(false, reader.readTokenAtEntry(999999));
        }
Beispiel #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());
        }
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
        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);
        }
Beispiel #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");
            }
        }
Beispiel #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);
            }
        }
Beispiel #11
0
        public void readTokenAtExitTestAnotherInvalidId()
        {
            var reader = new DigitalReader("Bus", "Victoria");

            reader.readTokenAtExit(999999, "Circle");
        }
Beispiel #12
0
 public void digitalReaderConstructionTestInvalidType()
 {
     var reader = new DigitalReader("Waffle Iron", "Victoria");
 }
Beispiel #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"));
        }
Beispiel #14
0
        public void readTokenAtEntryTestInsufficientFunds()
        {
            var reader = new DigitalReader("Bus", "Victoria");

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

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