예제 #1
0
        public async Task <JsonResult> getmonthwithmosthoilidays()
        {
            var date        = await CountrySingleton.Singleton;
            var countrycode = HolidayCalc.getmonthwithmosthoilidays(date.reuslt_holiday);


            return(new JsonResult(new { countrycode }));
        }
        public void getmonthwithmosthoilidays()
        {
            List <Holiday> result = new List <Holiday>();

            result.Add(new Holiday()
            {
                countryCode = "AD", date = new System.DateTime(2019, 1, 1, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AD", date = new System.DateTime(2019, 2, 1, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AD", date = new System.DateTime(2019, 3, 1, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AD", date = new System.DateTime(2019, 4, 1, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AD", date = new System.DateTime(2019, 5, 1, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AR", date = new System.DateTime(2019, 7, 1, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AT", date = new System.DateTime(2019, 8, 1, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AT", date = new System.DateTime(2019, 1, 2, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AT", date = new System.DateTime(2019, 1, 3, 1, 0, 0)
            });
            var testresult = HolidayCalc.getmonthwithmosthoilidays(result);

            Assert.AreEqual(testresult, "January");

            result.Add(new Holiday()
            {
                countryCode = "AR", date = new System.DateTime(2019, 2, 3, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AR", date = new System.DateTime(2019, 2, 4, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AR", date = new System.DateTime(2019, 2, 5, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AR", date = new System.DateTime(2019, 2, 6, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AR", date = new System.DateTime(2019, 2, 7, 1, 0, 0)
            });
            result.Add(new Holiday()
            {
                countryCode = "AR", date = new System.DateTime(2019, 2, 8, 1, 0, 0)
            });
            testresult = HolidayCalc.getmonthwithmosthoilidays(result);
            Assert.AreEqual(testresult, "February");
        }