Exemple #1
0
        public void TestJulianDateClass()
        {
            // Test Property Assignment
            foreach (JulianDateTestData testData in _testData)
            {
                Assert.AreEqual <DateTime>(testData.gregorian, JulianDate.ConvertToGregorian(testData.julian));
                Assert.AreEqual <int>(testData.julian, JulianDate.ConvertToJulian(testData.gregorian));
            }

            //// Test Erroneous Julian Date Assignments
            //foreach (JulianDateTestData testData in _testDataJulianToGregorian)
            //{
            //    jd = new JulianDate();
            //    jd.Julian = testData.julian;
            //    Assert.AreEqual<bool>(false, jd.IsValidDate);
            //}

            //// Test Erroneous Gregorian Date Assignments
            //foreach (JulianDateTestData testData in _testDataGregorianToJulian)
            //{
            //    jd = new JulianDate();
            //    jd.Gregorian = testData.gregorian;
            //    Assert.AreEqual<bool>(false, jd.IsValidDate);
            //}
        }
Exemple #2
0
        public void TestConvertGregorianToJulian()
        {
            List <JulianDateTestData> testDataList = new List <JulianDateTestData>();

            testDataList.AddRange(_testData);
            testDataList.AddRange(_testDataGregorianToJulian);

            foreach (JulianDateTestData testData in TestJulianDate._testData)
            {
                // Create the julian date
                try
                {
                    int julian = JulianDate.ConvertToJulian(testData.gregorian);
                    Assert.AreEqual <int>(testData.julian, julian);

                    Assert.AreEqual <bool>(testData.Exception, false);
                }
                catch (Exception)
                {
                    Assert.AreEqual <bool>(testData.Exception, true);
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Converts a <see cref="DateTime"/> to a Julian Date
 /// </summary>
 /// <param name="gregorian">The input DateTime</param>
 /// <returns>An <see cref="int"/> containing the Julian Date.</returns>
 public static int ToJulian(this DateTime gregorian)
 {
     return(JulianDate.ConvertToJulian(gregorian));
 }