public void TimedPassExpiredAtExitBarrier() { //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(); Station startStation = new Station("Newcastle"); Station endStation = new Station("Sheffield"); Ticket ticket = new Ticket(true, DateTime.Now.AddDays(-8), "timed", DateTime.Now.AddDays(-1), bobAccount.GetAccountId()); ticket.InitialiseTicketId(); ticket.InitialiseTickets(); //create an exit barrier with any station Scanner scanner = new Scanner(new Station(new DepartureList(), "Birmingham"), false); scanner.AddScannedTicket(ticket); Assert.IsFalse(scanner.ValidateTicket()); }
public void ValidAccountSaved() { AccountList accList = new AccountList(false); CustomerAccount bobAccount = new CustomerAccount(1, 38.50m, 1, "Bob", "password", "Bob Shanks", false); accList.AddCustomerAccount(bobAccount); Assert.AreEqual(accList.GetAccountById(bobAccount.GetAccountId()), bobAccount); }
public void SavedAccountComaparison() { AccountList accList = new AccountList(false); CustomerAccount bobAccount = new CustomerAccount(1, 38.50m, 1, "Bob", "password", "Bob Shanks", false); accList.AddCustomerAccount(bobAccount); accList.SaveCustomerData(); accList.LoadCustomerData(); var newAcc = accList.GetAccountById(bobAccount.GetAccountId()); Assert.IsTrue(bobAccount.ToString() == newAcc.ToString()); }
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()); }