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); }
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); }
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); }
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); }