Beispiel #1
0
        public void TestFormat()
        {
            DateController d = new DateController();

            d.InitializeDaysOfMonth();
            string sysDateFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;

            /*
             * The date format is based on the system date format, so if my machine is on MDY and
             * it is sent a date using DMY the program will treat the date as MDY.
             */
            long firstDate  = d.CalculateDaysOfADate("6-8-1830");
            long secondDate = d.CalculateDaysOfADate("3-11-2018");

            //If the system date format is MDY
            if (sysDateFormat.Equals("M/d/yyyy"))
            {
                Assert.AreEqual(secondDate - firstDate, 68577);
            }
            else if (sysDateFormat.Equals("dd/MM/yyyy"))
            {
                Assert.AreEqual(secondDate - firstDate, 68755);
            }
            else
            {
                Assert.AreEqual(secondDate - firstDate, -1);
            }
        }
Beispiel #2
0
        public void TestDaysDifference()
        {
            /*
             * According to Windows Calculator the difference of days between
             * June 8, 1830
             * and
             * March 11, 2018
             * is 68577
             */
            DateController d = new DateController();

            d.InitializeDaysOfMonth();

            /*
             * The date format is based on the system date format, so if my machine is on MDY and
             * it is sent a date using DMY the program will treat the date as MDY.
             */
            long   firstDate     = d.CalculateDaysOfADate("29/02/2018");
            long   secondDate    = d.CalculateDaysOfADate("3/11/2018");
            string sysDateFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;

            //If the system date format is MDY
            if (sysDateFormat.Equals("M/d/yyyy"))
            {
                Assert.AreEqual(secondDate - firstDate, 68577);
            }
            else if (sysDateFormat.Equals("dd/MM/yyyy"))
            {
                Assert.AreEqual(secondDate - firstDate, 68755);
            }
            else
            {
                Assert.AreEqual(secondDate - firstDate, -1);
            }
        }
Beispiel #3
0
        public void TestDaysDifferenceDMY()
        {
            /*
             * According to Windows Calculator the difference of days between
             * February 14, 1770
             * and
             * March 12, 2018
             * is 90606
             */
            DateController d = new DateController();

            d.InitializeDaysOfMonth();
            string sysDateFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;

            /*
             * The date format is based on the system date format, so if my machine is on MDY and
             * it is sent a date using DMY the program will treat the date as MDY.
             */
            long firstDate  = d.CalculateDaysOfADate("14/02/1770");
            long secondDate = d.CalculateDaysOfADate("12/03/2018");

            if (sysDateFormat.Equals("dd/MM/yyyy"))
            {
                Assert.AreEqual(secondDate - firstDate, 90606);
            }
            else if (sysDateFormat.Equals("M/d/yyyy"))
            {
                Assert.AreEqual(secondDate - firstDate, 737403);
            }
        }
Beispiel #4
0
 private void DateCalculation_Load(object sender, EventArgs e)
 {
     controller.InitializeDaysOfMonth();
 }