99using Microsoft . VisualStudio . TestTools . UnitTesting ;
1010using NCrontab . Advanced . Enumerations ;
1111using NCrontab . Advanced . Exceptions ;
12- using NCrontab . Advanced . Tests . Extensions ;
1312using System ;
1413using System . Diagnostics ;
1514using System . Globalization ;
@@ -26,13 +25,13 @@ public sealed class CronInstanceTests
2625 [ TestMethod ]
2726 public void CannotParseNullString ( )
2827 {
29- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( null ) ) ;
28+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( null ) ) ;
3029 }
3130
3231 [ TestMethod ]
3332 public void CannotParseEmptyString ( )
3433 {
35- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( string . Empty ) ) ;
34+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( string . Empty ) ) ;
3635 }
3736
3837 [ TestMethod ]
@@ -52,42 +51,42 @@ public void SixPartAllTimeString()
5251 [ TestMethod ]
5352 public void InvalidPatternCount ( )
5453 {
55- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * *" , CronStringFormat . Default ) ) ;
56- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * *" , CronStringFormat . Default ) ) ;
54+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * *" , CronStringFormat . Default ) ) ;
55+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * *" , CronStringFormat . Default ) ) ;
5756
58- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * *" , CronStringFormat . WithSeconds ) ) ;
59- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * * *" , CronStringFormat . WithSeconds ) ) ;
57+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * *" , CronStringFormat . WithSeconds ) ) ;
58+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * * *" , CronStringFormat . WithSeconds ) ) ;
6059
61- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * *" , CronStringFormat . WithYears ) ) ;
62- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * * *" , CronStringFormat . WithYears ) ) ;
60+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * *" , CronStringFormat . WithYears ) ) ;
61+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * * *" , CronStringFormat . WithYears ) ) ;
6362
64- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * *" , CronStringFormat . WithSecondsAndYears ) ) ;
65- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * * * *" , CronStringFormat . WithSecondsAndYears ) ) ;
63+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * *" , CronStringFormat . WithSecondsAndYears ) ) ;
64+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * * * *" , CronStringFormat . WithSecondsAndYears ) ) ;
6665 }
6766
6867 [ TestMethod ]
6968 public void OutOfBoundsValues ( )
7069 {
71- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "-1 * * * * *" , CronStringFormat . WithSeconds ) ) ;
72- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "60 * * * * *" , CronStringFormat . WithSeconds ) ) ;
70+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "-1 * * * * *" , CronStringFormat . WithSeconds ) ) ;
71+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "60 * * * * *" , CronStringFormat . WithSeconds ) ) ;
7372
74- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * 0" , CronStringFormat . WithYears ) ) ;
75- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * 10000" , CronStringFormat . WithYears ) ) ;
73+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * 0" , CronStringFormat . WithYears ) ) ;
74+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * * 10000" , CronStringFormat . WithYears ) ) ;
7675
77- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "-1 * * * *" , CronStringFormat . Default ) ) ;
78- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "60 * * * *" , CronStringFormat . Default ) ) ;
76+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "-1 * * * *" , CronStringFormat . Default ) ) ;
77+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "60 * * * *" , CronStringFormat . Default ) ) ;
7978
80- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* -1 * * *" , CronStringFormat . Default ) ) ;
81- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* 24 * * *" , CronStringFormat . Default ) ) ;
79+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* -1 * * *" , CronStringFormat . Default ) ) ;
80+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* 24 * * *" , CronStringFormat . Default ) ) ;
8281
83- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * 0 * *" , CronStringFormat . Default ) ) ;
84- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * 32 * *" , CronStringFormat . Default ) ) ;
82+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * 0 * *" , CronStringFormat . Default ) ) ;
83+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * 32 * *" , CronStringFormat . Default ) ) ;
8584
86- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * 0 *" , CronStringFormat . Default ) ) ;
87- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * 13 *" , CronStringFormat . Default ) ) ;
85+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * 0 *" , CronStringFormat . Default ) ) ;
86+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * 13 *" , CronStringFormat . Default ) ) ;
8887
89- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * -1" , CronStringFormat . Default ) ) ;
90- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * 8" , CronStringFormat . Default ) ) ;
88+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * -1" , CronStringFormat . Default ) ) ;
89+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * 8" , CronStringFormat . Default ) ) ;
9190 }
9291
9392 [ TestMethod ]
@@ -123,7 +122,7 @@ public void ThirtyFirstWeekdayForMonthsWithLessThanThirtyDaysProcessesCorrectly(
123122 [ TestMethod ]
124123 public void CannotParseWhenSecondsRequired ( )
125124 {
126- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * *" , CronStringFormat . WithSeconds ) ) ;
125+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( "* * * * *" , CronStringFormat . WithSeconds ) ) ;
127126 }
128127
129128 [ TestMethod ]
@@ -505,7 +504,7 @@ public void IllegalDates()
505504
506505 static void BadField ( string expression , CronStringFormat format )
507506 {
508- Assert2 . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( expression , format ) ) ;
507+ Assert . Throws < CrontabException > ( ( ) => CrontabSchedule . Parse ( expression , format ) ) ;
509508 }
510509
511510 [ TestMethod ]
@@ -615,7 +614,7 @@ public void MultipleInstancesTest()
615614
616615 var parser = CrontabSchedule . Parse ( cronString , CronStringFormat . WithYears ) ;
617616 var instances = parser . GetNextOccurrences ( input , DateTime . MaxValue ) . ToList ( ) ;
618- Assert . AreEqual ( 10 , instances . Count , "Make sure only 10 instances were generated" ) ;
617+ Assert . HasCount ( 10 , instances , "Make sure only 10 instances were generated" ) ;
619618
620619 // Now we'll manually iterate through getting values, and check the 11th and 12th
621620 // instance to make sure nothing blows up.
@@ -624,23 +623,23 @@ public void MultipleInstancesTest()
624623 newInput = parser . GetNextOccurrence ( newInput ) ;
625624
626625 Assert . IsTrue ( ( newInput = parser . GetNextOccurrence ( newInput ) ) == DateTime . MaxValue , "Make sure 11th instance is the endDate" ) ;
627- Assert . IsTrue ( ( newInput = parser . GetNextOccurrence ( newInput ) ) == DateTime . MaxValue , "Make sure 12th instance is the endDate" ) ;
626+ Assert . IsTrue ( parser . GetNextOccurrence ( newInput ) == DateTime . MaxValue , "Make sure 12th instance is the endDate" ) ;
628627 }
629628
630629 [ TestMethod ]
631630 public void NoNextInstanceTest ( )
632631 {
633632 var stopWatch = new Stopwatch ( ) ;
634633
635- var cron = NCrontab . Advanced . CrontabSchedule . Parse ( "0 0 1 1 * 0001" , NCrontab . Advanced . Enumerations . CronStringFormat . WithYears ) ;
634+ var cron = CrontabSchedule . Parse ( "0 0 1 1 * 0001" , CronStringFormat . WithYears ) ;
636635 var date = DateTime . Parse ( "0001-01-01" ) ;
637636
638637 stopWatch . Start ( ) ;
639638 var result = cron . GetNextOccurrence ( date ) ;
640639 stopWatch . Stop ( ) ;
641640
642641 Assert . AreEqual ( DateTime . MaxValue , result , "Next date returned is end date" ) ;
643- Assert . IsFalse ( stopWatch . ElapsedMilliseconds > 250 , string . Format ( "Elapsed time should not exceed 250ms (was {0 } ms)" , stopWatch . ElapsedMilliseconds ) ) ;
642+ Assert . IsLessThanOrEqualTo ( 250 , stopWatch . ElapsedMilliseconds , $ "Elapsed time should not exceed 250ms (was { stopWatch . ElapsedMilliseconds } ms)") ;
644643 }
645644
646645 [ TestMethod ]
@@ -765,8 +764,7 @@ static void CronCall(string startTimeString, string cronExpression, string nextT
765764 var schedule = CrontabSchedule . Parse ( cronExpression , format ) ;
766765 var next = schedule . GetNextOccurrence ( Time ( startTimeString ) ) ;
767766
768- var message = string . Format ( "Occurrence of <{0}> after <{1}>, format <{2}>." , cronExpression , startTimeString , Enum . GetName ( typeof ( CronStringFormat ) , format ) ) ;
769- Assert . AreEqual ( nextTimeString , TimeString ( next ) , message ) ;
767+ Assert . AreEqual ( nextTimeString , TimeString ( next ) , $ "Occurrence of <{ cronExpression } > after <{ startTimeString } >, format <{ Enum . GetName ( typeof ( CronStringFormat ) , format ) } >.") ;
770768 }
771769
772770 static void CronFinite ( string cronExpression , string startTimeString , string endTimeString , CronStringFormat format )
@@ -775,8 +773,7 @@ static void CronFinite(string cronExpression, string startTimeString, string end
775773 var occurrence = schedule . GetNextOccurrence ( Time ( startTimeString ) , Time ( endTimeString ) ) ;
776774
777775 Assert . AreEqual ( endTimeString , TimeString ( occurrence ) ,
778- "Occurrence of <{0}> after <{1}> did not terminate with <{2}>." ,
779- cronExpression , startTimeString , endTimeString ) ;
776+ $ "Occurrence of <{ cronExpression } > after <{ startTimeString } > did not terminate with <{ endTimeString } >.") ;
780777 }
781778
782779 static string TimeString ( DateTime time ) => time . ToString ( TimeFormat , CultureInfo . InvariantCulture ) ;
0 commit comments