public void TestGetAirTicketsCountReturnsCorrectValues()
 {
     ITicketCatalog catalog = new TicketCatalog();
     catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "Varna", airline: "Bulgaria Air", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 130.50M);
     catalog.AddAirTicket(flightNumber: "FX407", from: "Varna", to: "Sofia", airline: "Bulgaria Air", dateTime: new DateTime(2015, 2, 2, 7, 45, 00), price: 135.00M);
     Assert.AreEqual(2, catalog.GetTicketsCount(TicketType.Air));
 }
 public void TestGetTrainTicketsCountReturnsCorrectValues()
 {
     ITicketCatalog catalog = new TicketCatalog();
     catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 26.00M, studentPrice: 16.30M);
     catalog.AddTrainTicket(from: "Sofia", to: "Pleven", dateTime: new DateTime(2015, 1, 26, 8, 56, 00), price: 14.00M, studentPrice: 8.30M);
     Assert.AreEqual(2, catalog.GetTicketsCount(TicketType.Train));
 }
コード例 #3
0
        public void TestFindTicketsCheckDeletedTickets()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 211.00M, airline: "New Air", flightNumber: "SV1234");
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 25.00M, travelCompany: "Biomet");
            string cmdResult = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(1980, 1, 1, 0, 0, 0),
                endDateTime: new DateTime(2050, 2, 1, 0, 0, 0));
            string expectedCmdResult =
                "[28.01.2015 07:45; train; 26.00] " +
                "[29.01.2015 07:40; air; 211.00] " +
                "[29.01.2015 07:40; bus; 25.00]";
            Assert.AreEqual(expectedCmdResult, cmdResult);

            catalog.DeleteAirTicket(flightNumber: "SV1234");
            catalog.DeleteTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00));
            catalog.DeleteBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), travelCompany: "Biomet");
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Air));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Train));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Bus));
            string cmdResultFind = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(1980, 1, 1, 0, 0, 0),
                endDateTime: new DateTime(2050, 2, 1, 0, 0, 0));
            Assert.AreEqual("Not found", cmdResultFind);
        }
 public void TestGetTicketsCountEmptyReturns0()
 {
     ITicketCatalog catalog = new TicketCatalog();
     Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Air));
     Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Bus));
     Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Train));
 }
        public void TestGetAirTicketsCountReturnsCorrectValues()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "Varna", airline: "Bulgaria Air", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 130.50M);
            catalog.AddAirTicket(flightNumber: "FX407", from: "Varna", to: "Sofia", airline: "Bulgaria Air", dateTime: new DateTime(2015, 2, 2, 7, 45, 00), price: 135.00M);
            Assert.AreEqual(2, catalog.GetTicketsCount(TicketType.Air));
        }
        public void TestGetTrainTicketsCountReturnsCorrectValues()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddTrainTicket(from: "Sofia", to: "Pleven", dateTime: new DateTime(2015, 1, 26, 8, 56, 00), price: 14.00M, studentPrice: 8.30M);
            Assert.AreEqual(2, catalog.GetTicketsCount(TicketType.Train));
        }
        public void TestGetTicketsCountEmptyReturns0()
        {
            ITicketCatalog catalog = new TicketCatalog();

            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Air));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Bus));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Train));
        }
コード例 #8
0
        public void TestAddAirTicketReturnsTickedAdded()
        {
            ITicketCatalog catalog   = new TicketCatalog();
            string         cmdResult = catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "Varna", airline: "Bulgaria Air", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 130.50M);

            Assert.AreEqual("Ticket added", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
        }
 public void TestGetBusTicketsCountReturnsCorrectValues()
 {
     ITicketCatalog catalog = new TicketCatalog();
     catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 50, 00), price: 25.00M, travelCompany: "Biomet");
     catalog.AddBusTicket(from: "Sofia", to: "Pleven", dateTime: new DateTime(2015, 1, 29, 8, 00, 00), price: 12.00M, travelCompany: "Pleven Trans");
     catalog.AddBusTicket(from: "Varna", to: "Rousse", dateTime: new DateTime(2015, 1, 29, 7, 00, 00), price: 17.00M, travelCompany: "Etap");
     Assert.AreEqual(3, catalog.GetTicketsCount(TicketType.Bus));
 }
        public void TestAddTrainTicketReturnsTickedAdded()
        {
            ITicketCatalog catalog = new TicketCatalog();

            string cmdResult = catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);

            Assert.AreEqual("Ticket added", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Train));
        }
        public void TestAddAirTicketReturnsTickedAdded()
        {
            ITicketCatalog catalog = new TicketCatalog();
            
            string cmdResult = catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "Varna", airline: "Bulgaria Air", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 130.50M);

            Assert.AreEqual("Ticket added", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
        }
        public void TestAddBusTicketReturnsTickedAdded()
        {
            ITicketCatalog catalog = new TicketCatalog();
            
            string cmdResult = catalog.AddBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M);

            Assert.AreEqual("Ticket added", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Bus));
        }
        public void TestAddBusTicketReturnsTickedAdded()
        {
            ITicketCatalog catalog = new TicketCatalog();

            string cmdResult = catalog.AddBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M);

            Assert.AreEqual("Ticket added", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Bus));
        }
コード例 #14
0
        public void TestAddTrainTicketReturnsTickedAdded()
        {
            ITicketCatalog catalog = new TicketCatalog();

            string cmdResult = catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);

            Assert.AreEqual("Ticket added", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Train));
        }
        public void TestGetBusTicketsCountReturnsCorrectValues()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 50, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddBusTicket(from: "Sofia", to: "Pleven", dateTime: new DateTime(2015, 1, 29, 8, 00, 00), price: 12.00M, travelCompany: "Pleven Trans");
            catalog.AddBusTicket(from: "Varna", to: "Rousse", dateTime: new DateTime(2015, 1, 29, 7, 00, 00), price: 17.00M, travelCompany: "Etap");
            Assert.AreEqual(3, catalog.GetTicketsCount(TicketType.Bus));
        }
        public void TestAddAirTicketDuplicates()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "Varna", airline: "Bulgaria Air", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 130.50M);
            
            string cmdResult = catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "London", airline: "Wizz Air", dateTime: new DateTime(2015, 1, 22, 06, 15, 00), price: 730.55M);

            Assert.AreEqual("Duplicate ticket", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
        }
        public void TestAddAirTicketDuplicates()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "Varna", airline: "Bulgaria Air", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 130.50M);

            string cmdResult = catalog.AddAirTicket(flightNumber: "FX215", from: "Sofia", to: "London", airline: "Wizz Air", dateTime: new DateTime(2015, 1, 22, 06, 15, 00), price: 730.55M);

            Assert.AreEqual("Duplicate ticket", cmdResult);
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
        }
        public void TestDeleteDeletedBusTicketReturnsTickedDoesNotExist()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M);
            catalog.DeleteBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            string cmdResult = catalog.DeleteBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            Assert.AreEqual("Ticket does not exist", cmdResult);
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Bus));
        }
コード例 #19
0
 public void TryAddAnTrainTicketWithNegativeStudentPriceShouldThrowException()
 {
     var catalog = new TicketCatalog();
     var origin = "Sofia";
     var destination = "Berlin";
     string travelCompany = "BioMed";
     var departureDate = new DateTime(2015, 01, 20, 10, 10, 10);
     decimal price = 100m;
     decimal studentPrice = -80m;
     var busTicket = catalog.AddTrainTicket(origin, destination, departureDate, price, studentPrice);
 }
        public void TestDeleteDeletedTrainTicketReturnsTickedDoesNotExist()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.DeleteTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            string cmdResult = catalog.DeleteTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            Assert.AreEqual("Ticket does not exist", cmdResult);
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Train));
        }
コード例 #21
0
        public void TestDeleteDeletedTrainTicketReturnsTickedDoesNotExist()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.DeleteTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            string cmdResult = catalog.DeleteTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            Assert.AreEqual("Ticket does not exist", cmdResult);
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Train));
        }
        public void TestDeleteDeletedBusTicketReturnsTickedDoesNotExist()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M);
            catalog.DeleteBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            string cmdResult = catalog.DeleteBusTicket(from: "Sofia", to: "Varna", travelCompany: "BusExpress", dateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            Assert.AreEqual("Ticket does not exist", cmdResult);
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Bus));
        }
コード例 #23
0
 public void ShouldAddAnBusTicket()
 {
     var catalog = new TicketCatalog();
     var origin = "Sofia";
     var destination = "Berlin";
     string travelCompany = "BioMed";
     var departureDate = new DateTime(2015, 01, 20, 10, 10, 10);
     decimal price = 100m;
     var busTicket = catalog.AddBusTicket(origin, destination, travelCompany, departureDate, price);
     Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Bus));
     string expectedReport = "[20.01.2015 10:10; bus; 100.00]";
     Assert.AreEqual(expectedReport, catalog.FindTickets(origin, destination));
 }
コード例 #24
0
 public void ShouldAddAnAirTicket()
 {
     var catalog = new TicketCatalog();
     var flightNumber = "LZ001";
     var origin = "Sofia";
     var destination = "Marocco";
     string airline = "Balkan";
     var departureDate = new DateTime(2012, 01, 20, 10, 10, 10);
     decimal price = 100m;
     var airTicket = catalog.AddAirTicket(flightNumber, origin, destination, airline, departureDate, price);
     Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
     string expectedReport = "[20.01.2012 10:10; air; 100.00]";
     Assert.AreEqual(expectedReport, catalog.FindTickets(origin, destination));
 }
        public void TestFindTicketsReturnsNotFound()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddBusTicket(from: "Varna", to: "Sofia", dateTime: new DateTime(2015, 1, 30, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddTrainTicket(from: "SOFIA", to: "VARNA", dateTime: new DateTime(2015, 1, 23, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "sofia", to: "varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV7023");
            catalog.AddBusTicket(from: "Varna2", to: "Sofia2", dateTime: new DateTime(2015, 1, 25, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");

            string cmdResult = catalog.FindTickets(from: "Sofia", to: "Istanbul");

            Assert.AreEqual("Not found", cmdResult);
        }
コード例 #26
0
        public void TestFindTicketsReturnsNotFound()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddBusTicket(from: "Varna", to: "Sofia", dateTime: new DateTime(2015, 1, 30, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddTrainTicket(from: "SOFIA", to: "VARNA", dateTime: new DateTime(2015, 1, 23, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "sofia", to: "varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV7023");
            catalog.AddBusTicket(from: "Varna2", to: "Sofia2", dateTime: new DateTime(2015, 1, 25, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");

            string cmdResult = catalog.FindTickets(from: "Sofia", to: "Istanbul");

            Assert.AreEqual("Not found", cmdResult);
        }
        public void TestFindTicketsInIntervalReturnsNotFound()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV7023");
            catalog.AddAirTicket(from: "Sofia", to: "Plovdiv", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddBusTicket(from: "Varna", to: "Pleven", dateTime: new DateTime(2015, 1, 30, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddTrainTicket(from: "Sofia", to: "Veliko Tarnovo", dateTime: new DateTime(2015, 1, 23, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddBusTicket(from: "Varna", to: "Sofia", dateTime: new DateTime(2015, 1, 25, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");

            string cmdResult = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(2015, 1, 29, 7, 40, 01),
                endDateTime: new DateTime(2015, 1, 30, 11, 34, 59));

            Assert.AreEqual("Not found", cmdResult);
        }
コード例 #28
0
        public void TestFindTicketsInIntervalReturnsNotFound()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV7023");
            catalog.AddAirTicket(from: "Sofia", to: "Plovdiv", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddBusTicket(from: "Varna", to: "Pleven", dateTime: new DateTime(2015, 1, 30, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddTrainTicket(from: "Sofia", to: "Veliko Tarnovo", dateTime: new DateTime(2015, 1, 23, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddBusTicket(from: "Varna", to: "Sofia", dateTime: new DateTime(2015, 1, 25, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");

            string cmdResult = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(2015, 1, 29, 7, 40, 01),
                endDateTime: new DateTime(2015, 1, 30, 11, 34, 59));

            Assert.AreEqual("Not found", cmdResult);
        }
        public void TestGetTicketsCountForDeletedTicketsReturnsZero()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 211.00M, airline: "New Air", flightNumber: "SV1234");
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 25.00M, travelCompany: "Biomet");
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Train));
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Bus));

            catalog.DeleteAirTicket(flightNumber: "SV1234");
            catalog.DeleteTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00));
            catalog.DeleteBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), travelCompany: "Biomet");
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Air));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Train));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Bus));
        }
コード例 #30
0
        public void TestFindTicketsCheckCorrectSortingOrder()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 224.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 224.00M, airline: "Bulgaria Air", flightNumber: "SV453-2");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 211.00M, airline: "New Air", flightNumber: "SV1234");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 40, 00), price: 224.00M, airline: "Air BG", flightNumber: "S9473");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 1224.00M, airline: "Air Travel Corp.", flightNumber: "V245X");

            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 26, 7, 40, 00), price: 24.00M, studentPrice: 16.30M);
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 426.55M, studentPrice: 16.30M);

            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 25.00M, travelCompany: "Biomet2");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 28.00M, travelCompany: "Etap");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 27, 7, 40, 00), price: 25.00M, travelCompany: "New Bus Corp.");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 5.72M, travelCompany: "Sofia Bus Ltd.");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 1235.72M, travelCompany: "Varna Bus Travel Ltd.");

            string cmdResult = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(1980, 1, 1, 0, 0, 0),
                endDateTime: new DateTime(2050, 2, 1, 0, 0, 0));

            string expectedCmdResult =
                "[24.01.2015 07:40; train; 426.55] " +
                "[26.01.2015 07:40; train; 24.00] " +
                "[27.01.2015 07:40; bus; 25.00] " +
                "[28.01.2015 07:40; air; 224.00] " +
                "[28.01.2015 07:45; train; 26.00] " +
                "[29.01.2015 07:40; air; 211.00] " +
                "[29.01.2015 07:40; air; 224.00] " +
                "[29.01.2015 07:40; air; 224.00] " +
                "[29.01.2015 07:40; air; 1224.00] " +
                "[29.01.2015 07:40; bus; 5.72] " +
                "[29.01.2015 07:40; bus; 25.00] " +
                "[29.01.2015 07:40; bus; 25.00] " +
                "[29.01.2015 07:40; bus; 28.00] " +
                "[29.01.2015 07:40; bus; 1235.72] " +
                "[29.01.2015 07:40; train; 26.00]";

            Assert.AreEqual(expectedCmdResult, cmdResult);
        }
        public void TestFindTicketsInIntervalReturnsTickets()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV7023");
            catalog.AddAirTicket(from: "Sofia", to: "Plovdiv", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddBusTicket(from: "Varna", to: "Pleven", dateTime: new DateTime(2015, 1, 30, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddTrainTicket(from: "Sofia", to: "Veliko Tarnovo", dateTime: new DateTime(2015, 1, 23, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddBusTicket(from: "Varna", to: "Sofia", dateTime: new DateTime(2015, 1, 25, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");

            string cmdResult = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(2015, 1, 29, 7, 40, 00),
                endDateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            string expectedCmdResult =
                "[29.01.2015 07:40; air; 24.00] [30.01.2015 11:35; bus; 25.00] [30.01.2015 12:55; train; 26.00]";
            Assert.AreEqual(expectedCmdResult, cmdResult);
        }
        public void TestGetTicketsCountForDeletedTicketsReturnsZero()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 211.00M, airline: "New Air", flightNumber: "SV1234");
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 25.00M, travelCompany: "Biomet");
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Train));
            Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Bus));

            catalog.DeleteAirTicket(flightNumber: "SV1234");
            catalog.DeleteTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00));
            catalog.DeleteBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), travelCompany: "Biomet");
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Air));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Train));
            Assert.AreEqual(0, catalog.GetTicketsCount(TicketType.Bus));
        }
        public void TestFindTicketsCheckCorrectSortingOrder()
        {
            ITicketCatalog catalog = new TicketCatalog();
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 224.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 224.00M, airline: "Bulgaria Air", flightNumber: "SV453-2");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 211.00M, airline: "New Air", flightNumber: "SV1234");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 40, 00), price: 224.00M, airline: "Air BG", flightNumber: "S9473");
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 1224.00M, airline: "Air Travel Corp.", flightNumber: "V245X");

            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 26, 7, 40, 00), price: 24.00M, studentPrice: 16.30M);
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 28, 7, 45, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 426.55M, studentPrice: 16.30M);

            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 25.00M, travelCompany: "Biomet2");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 28.00M, travelCompany: "Etap");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 27, 7, 40, 00), price: 25.00M, travelCompany: "New Bus Corp.");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 5.72M, travelCompany: "Sofia Bus Ltd.");
            catalog.AddBusTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 1235.72M, travelCompany: "Varna Bus Travel Ltd.");

            string cmdResult = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(1980, 1, 1, 0, 0, 0),
                endDateTime: new DateTime(2050, 2, 1, 0, 0, 0));

            string expectedCmdResult =
                "[24.01.2015 07:40; train; 426.55] " +
                "[26.01.2015 07:40; train; 24.00] " +
                "[27.01.2015 07:40; bus; 25.00] " +
                "[28.01.2015 07:40; air; 224.00] " +
                "[28.01.2015 07:45; train; 26.00] " +
                "[29.01.2015 07:40; air; 211.00] " +
                "[29.01.2015 07:40; air; 224.00] " +
                "[29.01.2015 07:40; air; 224.00] " +
                "[29.01.2015 07:40; air; 1224.00] " +
                "[29.01.2015 07:40; bus; 5.72] " +
                "[29.01.2015 07:40; bus; 25.00] " +
                "[29.01.2015 07:40; bus; 25.00] " +
                "[29.01.2015 07:40; bus; 28.00] " +
                "[29.01.2015 07:40; bus; 1235.72] " +
                "[29.01.2015 07:40; train; 26.00]";
            Assert.AreEqual(expectedCmdResult, cmdResult);
        }
コード例 #34
0
        public void TestFindTicketsInIntervalReturnsTickets()
        {
            ITicketCatalog catalog = new TicketCatalog();

            catalog.AddTrainTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 30, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddAirTicket(from: "Sofia", to: "Varna", dateTime: new DateTime(2015, 1, 24, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV7023");
            catalog.AddAirTicket(from: "Sofia", to: "Plovdiv", dateTime: new DateTime(2015, 1, 29, 7, 40, 00), price: 24.00M, airline: "Bulgaria Air", flightNumber: "SV453");
            catalog.AddBusTicket(from: "Varna", to: "Pleven", dateTime: new DateTime(2015, 1, 30, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");
            catalog.AddTrainTicket(from: "Sofia", to: "Veliko Tarnovo", dateTime: new DateTime(2015, 1, 23, 12, 55, 00), price: 26.00M, studentPrice: 16.30M);
            catalog.AddBusTicket(from: "Varna", to: "Sofia", dateTime: new DateTime(2015, 1, 25, 11, 35, 00), price: 25.00M, travelCompany: "Biomet");

            string cmdResult = catalog.FindTicketsInInterval(
                startDateTime: new DateTime(2015, 1, 29, 7, 40, 00),
                endDateTime: new DateTime(2015, 1, 30, 12, 55, 00));

            string expectedCmdResult =
                "[29.01.2015 07:40; air; 24.00] [30.01.2015 11:35; bus; 25.00] [30.01.2015 12:55; train; 26.00]";

            Assert.AreEqual(expectedCmdResult, cmdResult);
        }
コード例 #35
0
 public void FindAllNonExisitngTicketsInIntervalShouldReturnMessage()
 {
     var catalog = new TicketCatalog();
     var destination = "Berlin";
     string travelCompany = "BioMed";
     var departureDateOne = new DateTime(2015, 01, 20, 10, 10, 10);
     var departureDateTwo = new DateTime(2015, 01, 20, 10, 20, 10);
     decimal price = 100m;
     decimal studentPrice = 80m;
     catalog.AddTrainTicket("Sofia", destination, departureDateOne, price, studentPrice);
     catalog.AddTrainTicket("Barcelona", destination, departureDateTwo, price, studentPrice);
     var actualMessage = catalog.FindTicketsInInterval(new DateTime(2011, 01, 01), new DateTime(2012, 01, 01));
     var expectedMessage = "Not found";
     Assert.AreEqual(expectedMessage, actualMessage);
 }
コード例 #36
0
        public void DeleteExistingBusTicketShouldReturnMessage()
        {
            var catalog = new TicketCatalog();
            var origin = "Sofia";
            var destination = "Berlin";
            string travelCompany = "BioMed";
            var departureDate = new DateTime(2015, 01, 20, 10, 10, 10);
            decimal price = 100m;
            var actualMessage = catalog.AddBusTicket(origin, destination, travelCompany, departureDate, price);
            Assert.AreEqual("Ticket added", actualMessage);
            actualMessage = catalog.DeleteBusTicket(origin, destination, travelCompany, departureDate);
            Assert.AreEqual("Ticket deleted", actualMessage);

        }
コード例 #37
0
 public void TryToDuplicateAnAirTicketShouldReturnMessage()
 {
     var catalog = new TicketCatalog();
     var flightNumber = "LZ001";
     var origin = "Sofia";
     var destination = "Marocco";
     string airline = "Balkan";
     var departureDate = new DateTime(2012, 01, 20, 10, 10, 10);
     decimal price = 100m;
     var actualMessage = catalog.AddAirTicket(flightNumber, origin, destination, airline, departureDate, price);
     Assert.AreEqual("Ticket added", actualMessage);
     actualMessage = catalog.AddAirTicket(flightNumber, origin, destination, airline, departureDate, price);
     Assert.AreEqual("Duplicate ticket", actualMessage);
 }
コード例 #38
0
 public void DeleteAnAirTicketThatDoNotExistShouldReturnMessage()
 {
     var catalog = new TicketCatalog();
     var flightNumber = "LZ001";
     var origin = "Sofia";
     var destination = "Marocco";
     string airline = "Balkan";
     var departureDate = new DateTime(2012, 01, 20, 10, 10, 10);
     decimal price = 100m;
     var airTicket = catalog.AddAirTicket(flightNumber, origin, destination, airline, departureDate, price);
     Assert.AreEqual(1, catalog.GetTicketsCount(TicketType.Air));
     var actualMessage = catalog.DeleteAirTicket("MH1001");
     string expectedMessage = "Ticket does not exist";
     Assert.AreEqual(expectedMessage, actualMessage);
 }
コード例 #39
0
 public void DeleteAnTrainTicketThatExistShouldReturnMessage()
 {
     var catalog = new TicketCatalog();
     var origin = "Sofia";
     var destination = "Berlin";
     string travelCompany = "BioMed";
     var departureDate = new DateTime(2015, 01, 20, 10, 10, 10);
     decimal price = 100m;
     decimal studentPrice = 80m;
     var actualMessage = catalog.AddTrainTicket(origin, destination, departureDate, price, studentPrice);
     actualMessage = catalog.DeleteTrainTicket(origin, destination, departureDate);
     string expectedMessage = "Ticket deleted";
     Assert.AreEqual(expectedMessage, actualMessage);
 }
コード例 #40
0
 public void TryAddAnAirTicketWithBlankflightNumberShouldThrowException()
 {
     var catalog = new TicketCatalog();
     string flightNumber = "LZ0112";
     var origin = "Sofia";
     var destination = "Marocco";
     string airline = "";
     var departureDate = new DateTime(2012, 01, 20, 10, 10, 10);
     decimal price = 100m;
     var airTicket = catalog.AddAirTicket(flightNumber, origin, destination, airline, departureDate, price);
 }
コード例 #41
0
 public void FindAllNonExistingTicketsShouldReturnMessage()
 {
     var catalog = new TicketCatalog();
     var origin = "Sofia";
     var destination = "Berlin";
     string travelCompany = "BioMed";
     var departureDate = new DateTime(2015, 01, 20, 10, 10, 10);
     decimal price = 100m;
     decimal studentPrice = 80m;
     var actualMessage = catalog.AddTrainTicket(origin, destination, departureDate, price, studentPrice);
     actualMessage = catalog.FindTickets("Barcelona", "Sofia");
     string expectedMessage = "Not found";
     Assert.AreEqual(expectedMessage, actualMessage);
 }
コード例 #42
0
 public void DeleteAnBusTicketThatDoNotExistShouldReturnMessage()
 {
     var catalog = new TicketCatalog();
     var origin = "Sofia";
     var destination = "Berlin";
     string travelCompany = "BioMed";
     var departureDate = new DateTime(2015, 01, 20, 10, 10, 10);
     decimal price = 100m;
     var actualMessage = catalog.AddBusTicket(origin, destination, travelCompany, departureDate, price);
     actualMessage = catalog.DeleteBusTicket(origin, destination, "MontanaBus", departureDate);
     string expectedMessage = "Ticket does not exist";
     Assert.AreEqual(expectedMessage, actualMessage);
 }
コード例 #43
0
 public void CatalogInitialize()
 {
     this.catalog = new TicketCatalog();
 }