Ejemplo n.º 1
0
        public void AddTravelTest()
        {
            var myTravelManager = new TravelSearchManager(new ITravelSearchEngine[0]);

            var travels = new List<Travel>{
                new Travel("London", "Budapest", DateTime.Today.AddDays(4)),
                new Travel("Budapest", "London", DateTime.Today.AddDays(10)),
                new Travel("London", "Budapest", DateTime.Today.AddDays(11)),
                new Travel("Budapest", "London", DateTime.Today.AddDays(20)),
                new Travel("London", "Budapest", DateTime.Today.AddDays(21))
            };
            foreach (var t in travels)
                myTravelManager.AddTravel(t);
            myTravelManager.AddTravel("Budapest", "London", DateTime.Today.AddDays(3));
            Debug.Assert(myTravelManager.Travels.Count == 6);
            Debug.Assert(
                    myTravelManager.Travels[0].Equals(travels[0]) &&
                    myTravelManager.Travels[1].Equals(travels[1]) &&
                    myTravelManager.Travels[2].Equals(travels[2]) &&
                    myTravelManager.Travels[3].Equals(travels[3]) &&
                    myTravelManager.Travels[4].Equals(travels[4]) &&
                    myTravelManager.Travels[5].Equals(new Travel("Budapest", "London", DateTime.Today.AddDays(3))));
        }
Ejemplo n.º 2
0
        public void CancelSearchTest()
        {
            var mockEngine = new MockSearchEngine(1);
            var myTravelManager = new TravelSearchManager(new[] { mockEngine });

            var travels = new List<Travel>{
                new Travel("Budapest", "London", DateTime.Today.AddDays(3)),
                new Travel("London", "Budapest", DateTime.Today.AddDays(4))
            };

            foreach (var t in travels)
                myTravelManager.AddTravel(t);

            myTravelManager.StartSearch();

            myTravelManager.CancelSearch();

            Debug.Assert(!mockEngine.searchinprogress);
        }
Ejemplo n.º 3
0
        public void GetProgressTest()
        {
            var mockEngine = new MockSearchEngine(1);
            var mockEngine2 = new MockSearchEngine(2);
            var myTravelManager = new TravelSearchManager(new[] { mockEngine, mockEngine2 });

            var travels = new List<Travel>{
                new Travel("Budapest", "London", DateTime.Today.AddDays(3)),
                new Travel("London", "Budapest", DateTime.Today.AddDays(4))
            };

            foreach (var t in travels)
                myTravelManager.AddTravel(t);

            myTravelManager.StartSearch();
            Debug.Assert(myTravelManager.GetProgress() == 15);
        }
Ejemplo n.º 4
0
        public void GetResultTest3()
        {
            var mockEngine = new MockSearchEngine(1);
            var mockEngine2 = new MockSearchEngine(2);
            var myTravelManager = new TravelSearchManager(new[] { mockEngine, mockEngine2 });

            var travels = new List<Travel>{
                new Travel("Budapest", "London", DateTime.Today.AddDays(3)),
                new Travel("London", "Budapest", DateTime.Today.AddDays(4)),
                new Travel("Budapest", "London", DateTime.Today.AddDays(20)),
                new Travel("London", "Budapest", DateTime.Today.AddDays(22))
            };

            foreach (var t in travels)
                myTravelManager.AddTravel(t);

            myTravelManager.StartSearch();
            var results = myTravelManager.GetResults().ToList();

            Debug.Assert(results.Count == 56 &&
                results.Count(a => a.TicketCount == 4) == 16 &&
                results.Count(a => a.TicketCount == 3) == 32 &&
                results.Count(a => a.TicketCount == 2) == 8);
        }
Ejemplo n.º 5
0
        public void GetResultTest()
        {
            var mockEngine = new MockSearchEngine(1);
            var myTravelManager = new TravelSearchManager(new[] { mockEngine });

            var travels = new List<Travel>{
                new Travel("Budapest", "London", DateTime.Today.AddDays(3)),
                new Travel("London", "Budapest", DateTime.Today.AddDays(4))
            };

            foreach (var t in travels)
                myTravelManager.AddTravel(t);

            myTravelManager.StartSearch();
            var results = myTravelManager.GetResults();

            Debug.Assert(
                results.Count == 2);
        }