static void Main(string[] args) { var filePath = @"..\..\..\test-case.json"; if (args.Length == 0) { Console.WriteLine("No file supplied, using default \"test-case.json\" file."); } if (args.Length > 0) { if (File.Exists(args[0])) { Console.WriteLine($"Using the specified \"{args[0]}\" file."); filePath = args[0]; } else { Console.WriteLine($"Could not find the specified \"{args[0]}\" file, using default \"test-case.json\" file."); } } ImportTestCases importTestCases = new ImportTestCases(filePath); SearchQueryRepository searchQueryRepository = new SearchQueryRepository(importTestCases); IReservationEngine engine = ReservationEngineFactory.Create(filePath); var availableCampsites = engine.GetAvailableCampsitesForSearchQuery(searchQueryRepository.GetSearchQuery()); foreach (var campsite in availableCampsites) { Console.WriteLine($"{campsite.Id} - {campsite.Name}"); } Console.ReadKey(); }
public void ShouldGetAvailableCampsitesForDifferentGapSize() { var filePath = @"..\..\..\test-case3.json"; ImportTestCases test = new ImportTestCases(filePath); ISearchQueryRepository searchQueryRepository = new SearchQueryRepository(test); IReservationEngine engine = ReservationEngineFactory.Create(filePath); var data = engine.GetAvailableCampsitesForSearchQuery(searchQueryRepository.GetSearchQuery()).ToList(); Assert.IsTrue(data.Exists(x => x.Id == 1)); Assert.IsFalse(data.Exists(x => x.Id == 2)); Assert.IsFalse(data.Exists(x => x.Id == 3)); Assert.IsFalse(data.Exists(x => x.Id == 4)); Assert.IsFalse(data.Exists(x => x.Id == 5)); Assert.IsFalse(data.Exists(x => x.Id == 6)); Assert.IsTrue(data.Exists(x => x.Id == 7)); Assert.IsFalse(data.Exists(x => x.Id == 8)); Assert.IsFalse(data.Exists(x => x.Id == 9)); }