Example #1
0
        public void WeekDateFromComponentsOutOfRangeTest()
        {
            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                new WeekDate(0, 1, 1);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                new WeekDate(10000, 1, 1);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                new WeekDate(2000, 0, 1);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                new WeekDate(2000, WeekDate.GetWeeksInYear(2000) + 1, 1);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                new WeekDate(2000, 1, 0);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                new WeekDate(2000, 1, 8);
            });
        }
Example #2
0
 public void GetYearTest()
 {
     foreach (var convertedDate in DateTimesByWeekDates)
     {
         Assert.AreEqual(
             convertedDate.Key.Year,
             WeekDate.GetYear(convertedDate.Value));
     }
 }
Example #3
0
 public void GetWeekdayNumberTest()
 {
     foreach (var dayOfWeek in DaysOfWeek)
     {
         Assert.AreEqual(
             dayOfWeek.Key,
             WeekDate.GetWeekdayNumber(dayOfWeek.Value));
     }
 }
Example #4
0
 public void GetWeeksInYearTest()
 {
     for (int year = 1; year <= CycleLength; year++)
     {
         Assert.AreEqual(
             LongYears.Contains(year) ? 53 : 52,
             WeekDate.GetWeeksInYear(year),
             $"{year}");
     }
 }
Example #5
0
        public void ParseExactFormatSpecifiersTest()
        {
            foreach (KeyValuePair <KeyValuePair <string, string>, WeekDate> weekDateByFormat in WeekDatesByFormats)
            {
                Assert.AreEqual(
                    weekDateByFormat.Value,
                    WeekDate.ParseExact(weekDateByFormat.Key.Value, weekDateByFormat.Key.Key),
                    $"Format: {weekDateByFormat.Key.Key}; String: {weekDateByFormat.Key.Value}");

                Assert.AreEqual(
                    weekDateByFormat.Value,
                    WeekDate.ParseExact(weekDateByFormat.Key.Value, WeekDate.Formats[weekDateByFormat.Key.Key]),
                    $"Format: {WeekDate.Formats[weekDateByFormat.Key.Key]}; String: {weekDateByFormat.Key.Value}");
            }
        }
Example #6
0
 public void ParseExactInvalidFormatStringTest()
 {
     WeekDate.ParseExact("2019-W10-1", DateTimeFormatInfo.InvariantInfo.FullDateTimePattern);
 }
Example #7
0
 public void ParseExactEmptyFormatStringTest()
 {
     WeekDate.ParseExact("2019-W10-1", string.Empty);
 }
Example #8
0
 public void ParseExactEmptySourceStringTest()
 {
     WeekDate.ParseExact(string.Empty, "d");
 }
Example #9
0
 public void ParseExactNullFormatStringTest()
 {
     WeekDate.ParseExact("2019-W10-1", null);
 }
Example #10
0
 public void ParseExactNullSourceStringTest()
 {
     WeekDate.ParseExact(null, "d");
 }
Example #11
0
 public void GetWeekdayNumberArgumentOutOfRangeTest()
 {
     WeekDate.GetWeekdayNumber((DayOfWeek)8);
 }
Example #12
0
 public void GetWeeksInYearMoreThanMaximalTest()
 {
     WeekDate.GetWeeksInYear(10000);
 }
Example #13
0
 public void GetWeeksInYearLessThanMinimalTest()
 {
     WeekDate.GetWeeksInYear(-1);
 }