Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Testing Date class");
            Date d1 = new Date(2020, 10, 1);

            Console.WriteLine("Calling isToday: " + d1.IsToday());
            Console.WriteLine(d1);
            Console.WriteLine(d1.MonthName);
            Console.WriteLine(d1.MonthNameAbbrev);
            HolidayProvider hp   = new HolidayProvider();
            List <Holiday>  list = hp.GetHolidays(2020);

            foreach (Holiday h in list)
            {
                Console.WriteLine($"{h.TheDate} - {h.Name}");
            }
        }
Ejemplo n.º 2
0
        public string WhatHolidayIsOnThisDay()
        {
            //assume this is an external dependency - code that you don't control or test
            //can't predict what these dates will be when writing tests
            HolidayProvider _holidayProvider = new HolidayProvider();
            List <Holiday>  list             = _holidayProvider.GetHolidays(Year);

            foreach (Holiday holiday in list)
            {
                //add code later to handle if two holidays are in the list for this day
                if (holiday.TheDate.Month == Month && holiday.TheDate.Day == Day)
                {
                    return(holiday.Name);
                }
            }
            return(null);
        }