public void TestDeleteNotExistingBusTicketReturntsBusDoesNotExist()
        {
            ITicketRepository repository = new TicketRepository();
            repository.AddBusTicket("Sofia", "Varna", "BusExpress", new DateTime(2015, 1, 30, 12, 55, 00), 26.00M);

            string cmdResult = repository.DeleteBusTicket("Plovdiv", "Varna", "BusExpress", new DateTime(2015, 1, 30, 12, 55, 00));

            Assert.AreEqual("Bus does not exist", cmdResult);
            Assert.AreEqual(1, repository.GetTicketsCount(TicketType.Bus));
        }
        public void TestFindSingleTicket()
        {
            ITicketRepository repository = new TicketRepository();
            repository.AddBusTicket("Sofia", "Varna", "Etap Address", new DateTime(2015, 1, 30, 12, 55, 00), 25m);

            string actualOutput = repository.FindTickets("Sofia", "Varna");
            string expectedOutput = "[30.01.2015 12:55|bus|25.00]";

            Assert.AreEqual(expectedOutput, actualOutput);
        }
        public void TestDeleteExistingBusTicketReturnsBusDeleted()
        {
            ITicketRepository repository = new TicketRepository();
            string cmdResult = repository.AddBusTicket("Sofia", "Varna", "BusExpress", new DateTime(2015, 1, 30, 12, 55, 00), 26.00M);

            string cmdResultDeleted = repository.DeleteBusTicket("Sofia", "Varna", "BusExpress", new DateTime(2015, 1, 30, 12, 55, 00));

            Assert.AreEqual("Bus deleted", cmdResultDeleted);
            Assert.AreEqual(0, repository.GetTicketsCount(TicketType.Bus));
            Assert.AreNotEqual(cmdResult, cmdResultDeleted);
        }
        public void TestFindNonExistingTickets()
        {
            ITicketRepository repository = new TicketRepository();
            repository.AddBusTicket("Sofia", "Varna", "Etap Address", new DateTime(2015, 1, 30, 12, 55, 00), 25m);
            repository.AddAirTicket("FX215", "Sofia", "Varna", "Bulgaria Air", new DateTime(2015, 1, 30, 12, 55, 00), 130.50M);
            repository.AddTrainTicket("Sofia", "Varna", new DateTime(2015, 1, 30, 12, 55, 00), 55m, 35m);

            string actualOutput = repository.FindTickets("Plovdiv", "Varna");
            string expectedOutput = "No matches";

            Assert.AreEqual(expectedOutput, actualOutput);
        }
        public void TestFindMultipleTickets()
        {
            ITicketRepository repository = new TicketRepository();
            repository.AddBusTicket("Sofia", "Varna", "Etap Address", new DateTime(2015, 1, 30, 12, 55, 00), 25m);
            repository.AddAirTicket("FX215", "Sofia", "Varna", "Bulgaria Air", new DateTime(2015, 1, 30, 12, 55, 00), 130.50M);
            repository.AddTrainTicket("Sofia", "Varna", new DateTime(2015, 1, 30, 12, 55, 00), 55m, 35m);

            string actualOutput = repository.FindTickets("Sofia", "Varna");
            string expectedOutput =
                "[30.01.2015 12:55|bus|25.00] [30.01.2015 12:55|flight|130.50] [30.01.2015 12:55|train|55.00]";

            Assert.AreEqual(expectedOutput, actualOutput);
        }
        private static void Main()
        {
            TicketRepository ticket = new TicketRepository();
            while (true)
            {
                string inputLine = Console.ReadLine();
                if (inputLine == null)
                {
                    break;
                }

                inputLine = inputLine.Trim();
                string commandResult = ticket.CommandExecutor(inputLine);
                if (commandResult != null)
                {
                    Console.WriteLine(commandResult);
                }
            }
        }
示例#7
0
        private static void Main()
        {
            TicketRepository ticket = new TicketRepository();

            while (true)
            {
                string inputLine = Console.ReadLine();
                if (inputLine == null)
                {
                    break;
                }

                inputLine = inputLine.Trim();
                string commandResult = ticket.CommandExecutor(inputLine);
                if (commandResult != null)
                {
                    Console.WriteLine(commandResult);
                }
            }
        }