Exemplo n.º 1
0
        public void TestCompareToSameType(int lowYear, int highYear)
        {
            YearAsParam low  = new YearAsParam(lowYear);
            YearAsParam high = new YearAsParam(highYear);

            Assert.AreEqual(lowYear.CompareTo(highYear), low.CompareTo(high));
            Assert.AreEqual(highYear.CompareTo(lowYear), high.CompareTo(low));
            Assert.AreEqual(lowYear.CompareTo(lowYear), low.CompareTo(low));
        }
Exemplo n.º 2
0
        public void TestCompareToDifferentType()
        {
            int         testYear    = 2020;
            YearAsParam yearAsParam = new YearAsParam(testYear);

            DateAsParam lowCompareDate      = new DateAsParam("2010-01-01");
            DateAsParam highCompareDate     = new DateAsParam("2021-01-01");
            DateAsParam sameYearCompareDate = new DateAsParam("2020-01-01");

            Assert.AreEqual(1, yearAsParam.CompareTo(lowCompareDate));          // lowCompareDate is before than the startDate of the testYear
            Assert.AreEqual(-1, yearAsParam.CompareTo(highCompareDate));        // lowCompareDate is after the endDate of the testYear
            Assert.AreEqual(0, yearAsParam.CompareTo(sameYearCompareDate));     // sameYearCompare date is in the same year
        }
Exemplo n.º 3
0
        public void TestClassCreation(int testYear)
        {
            YearAsParam yearAsParam = new YearAsParam(testYear);

            DateTime startDate = DateTime.Parse($"{testYear}-01-01");
            DateTime endDate   = DateTime.Parse($"{testYear}-12-31");

            string expectedStart = $"'{startDate.ToString("yyyy-MM-dd")}'";
            string expectedEnd   = $"'{endDate.ToString("yyyy-MM-dd")}'";

            Assert.AreEqual(expectedStart, yearAsParam.YearStart.ToString());
            Assert.AreEqual(expectedEnd, yearAsParam.YearEnd.ToString());
        }