示例#1
0
        public void AllValidCampSiteIds()
        {
            var parseFile   = new ParseFile <RootObject>();
            var root        = parseFile.ReadJsonFile(filename);
            var campSiteIds = root.campsites.Select(s => s.id);

            var loadReservation  = new LoadReservation();
            var reservationsList = loadReservation.LoadReservationsList(campSiteIds, root);

            var gapRule   = new GapRule();
            var campsites = gapRule.ApplyGapRule(reservationsList, campSiteIds, root.search.startDateOfYear, root.search.endDateOfYear, 1);

            CollectionAssert.AreEqual(campsites, new List <int>(new int[] { 2, 4, 5 }));
        }
示例#2
0
        public void AllValidCampSiteNames()
        {
            var parseFile   = new ParseFile <RootObject>();
            var root        = parseFile.ReadJsonFile(filename);
            var campSiteIds = root.campsites.Select(s => s.id);

            var loadReservation  = new LoadReservation();
            var reservationsList = loadReservation.LoadReservationsList(campSiteIds, root);

            var gapRule   = new GapRule();
            var campsites = gapRule.ApplyGapRule(reservationsList, campSiteIds, root.search.startDateOfYear, root.search.endDateOfYear, 1);

            List <string> campSiteNames = new List <string>();

            foreach (int campsiteId in campsites)
            {
                campSiteNames.Add(root.campsites.Find(c => c.id == campsiteId).name);
            }

            CollectionAssert.AreEqual(campSiteNames, new List <string>(new string[] { "Comfy Cabin", "Rickety Cabin", "Cabin in the Woods" }));
        }
示例#3
0
        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                filename = args[0];
            }

            if (File.Exists(filename))
            {
                Console.WriteLine("Processing " + filename);
            }
            else
            {
                Console.WriteLine("Please provdie a fully qualified json filename");
            }

            var parseFile   = new ParseFile <RootObject>();
            var root        = parseFile.ReadJsonFile(filename);
            var campSiteIds = root.campsites.Select(s => s.id);

            var loadReservation  = new LoadReservation();
            var reservationsList = loadReservation.LoadReservationsList(campSiteIds, root);

            var gapRule   = new GapRule();
            var campsites = gapRule.ApplyGapRule(reservationsList, campSiteIds, root.search.startDateOfYear, root.search.endDateOfYear, 1);

            foreach (int campsiteId in campsites)
            {
                Console.WriteLine(root.campsites.Find(c => c.id == campsiteId).name);
            }

            Console.WriteLine("Press ESC to stop");
            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
            {
            }
        }