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()); }
public void TestRouteListSubject() { RouteList routes = new RouteList(); MockObserver observer1 = new MockObserver(); MockObserver observer2 = new MockObserver(); WriteToBinaryFile <List <Ticket> >(@"Berlin_tickets.txt", new List <Ticket>(), false); WriteToBinaryFile <List <Ticket> >(@"Paris_tickets.txt", new List <Ticket>(), false); Station Berlin = new Station("Berlin"); Station Paris = new Station("Paris"); Route BerlinParis = new Route(Berlin, Paris, 1234.00m); routes.RegisterObserver(observer1); routes.RegisterObserver(observer2); routes.AddRoute(BerlinParis); Assert.IsTrue(observer1.GetRoutes() == routes.GetAllRoutes()); Assert.IsTrue(observer2.GetRoutes() == routes.GetAllRoutes()); File.Delete(@"Berlin_tickets.txt"); }