public async Task <string> GetLongestLastingHolidaySequanceAsync(int year) { RequestAllCountriesHolidays(year); var timeZones = await RequestContryZonesAsync(); var holidayIntervals = HolidayIntervalsProcessor.CalculateHolidayIntervals(timeZones, _dayOfTheYearsMap); var mergedHolidayIntervals = HolidayIntervalsProcessor.MergeHolidayIntervals(holidayIntervals); var longestHolidaySequance = mergedHolidayIntervals[mergedHolidayIntervals.Count - 1].End - mergedHolidayIntervals[mergedHolidayIntervals.Count - 1].Start; string formatedString = String.Format("The longest lasting sequence of holidays around the world is {0} hours", longestHolidaySequance); return(formatedString); }
public void CalculateHolidayIntervals_ShouldRturnMapedUTCIntervals() { Dictionary <string, IList <string> > contryTimeZones = new Dictionary <string, IList <string> >(); contryTimeZones.Add("Au", new List <string>() { "UTC+01:00", "UTC", "UTC-01:00" }); Dictionary <int, HashSet <string> > daysAndCountryCodesMap = new Dictionary <int, HashSet <string> >(); daysAndCountryCodesMap.Add(1, new HashSet <string>() { "Au" }); // vacation at first day of the year at Au List <IHoldiayInterval> intervals = HolidayIntervalsProcessor.CalculateHolidayIntervals(contryTimeZones, daysAndCountryCodesMap); List <IHoldiayInterval> expectedResult = new List <IHoldiayInterval>() { new HoldiayInterval(25, 49), new HoldiayInterval(24, 48), new HoldiayInterval(23, 47) }; expectedResult.Should().BeEquivalentTo(expectedResult); }