Beispiel #1
0
        public void Get_CarPark_Succeeds()
        {
            IEnumerable <KeyValuePair <ParkingStrategyType, IParkingStrategy> > parkingStrategies = GetShortStayStrategy();
            var carPark = CarParkFactory.Create(parkingStrategies);

            Assert.IsNotNull(carPark);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Novia Parking Charge Calculator");

            var parkingStrategies = GetShortStayStrategy().Concat(GetLongStayStrategy());
            var carPark           = CarParkFactory.Create(parkingStrategies);

            //·  A short stay from 07 / 09 / 2017 16:50:00 to 09 / 09 / 2017 19:15:00 would cost £12.28
            var startTime = new DateTime(2017, 9, 7, 16, 50, 0);
            var endTime   = new DateTime(2017, 9, 9, 19, 15, 0);
            var charge    = carPark.CalculateParkingCharge(ParkingStrategyType.ShortStay, startTime, endTime);

            Console.WriteLine($"Calculation for short term parking from {startTime.ToString("dd/MMM/yyyy HH:mm")} to {endTime.ToString("dd/MMM/yyyy HH:mm")} is: {charge.ToString("#.#0")}");

            //·  A long stay from 07 / 09 / 2017 07:50:00 to 09 / 09 / 2017 05:20:00 would cost £22.50
            startTime = new DateTime(2017, 9, 7, 07, 50, 0);
            endTime   = new DateTime(2017, 9, 9, 05, 20, 0);
            charge    = carPark.CalculateParkingCharge(ParkingStrategyType.LongStay, startTime, endTime);
            Console.WriteLine($"Calculation for long term parking from {startTime.ToString("dd/MMM/yyyy HH:mm")} to {endTime.ToString("dd/MMM/yyyy HH:mm")} is: {charge.ToString("#.#0")}");

            Console.WriteLine("\n\n\nPress eny key to EXIT");
            Console.ReadLine();
        }