Пример #1
0
        public void SingleJourneyTicketAtCorrectExitScannerReuseTest()
        {
            //setup for ticket and file creation
            Ticket initTicket = new Ticket();

            initTicket.InitialiseTicketId();

            CustomerAccount bobAccount = new CustomerAccount(1, 38.50m, 1, "Bob", "password", "Bob Shanks", false);
            AccountList     accList    = new AccountList(false);

            accList.AddCustomerAccount(bobAccount);
            accList.SaveCustomerData();

            DepartureList departureList = new DepartureList();

            departureList.AddDeparture(new Departure(new Station("Sheffield"), new DateTime(2017, 02, 20, 15, 05, 0)));

            Station startStation = new Station(departureList, "Newcastle");
            Station endStation   = new Station(new DepartureList(), "Sheffield");

            RouteList startStationRouteList = new RouteList();

            startStationRouteList.AddRoute(new Route(startStation, endStation, 2.70m));

            Route route = startStationRouteList.GetRouteByStations(startStation, endStation);

            Ticket ticket = new Ticket(route, true, DateTime.Now, null, "single", bobAccount.GetAccountId());

            ticket.InitialiseTicketId();
            startStation.InitialiseTicketList(ticket);
            endStation.InitialiseTicketList(ticket);

            //create an exit scanner with the correct end station
            Scanner scanner = new Scanner(endStation, false);

            scanner.AddScannedTicket(ticket);
            scanner.ValidateTicket();

            //try to use the ticket at the same barrier again (should fail)
            Assert.IsFalse(scanner.ValidateTicket());
        }