public void IsOngoing_OneTimes_TrueThenFalse() { var strategy = new CountDateTimeLoopStrategy(1, new DateTime(2015, 1, 1), new FixedDuration(new TimeSpan(1, 0, 0, 0))); Assert.That(strategy.IsOngoing(), Is.True); strategy.GetNext(); Assert.That(strategy.IsOngoing(), Is.False); }
public void Run_MonthDuration_CorrectResult(int count, int stepYear, int expectedYear) { var strategy = new CountDateTimeLoopStrategy(count, new DateTime(2018, 1, 1), new YearDuration(stepYear)); var final = DateTime.MinValue; while (strategy.IsOngoing()) { final = strategy.GetNext(); } Assert.That(final, Is.EqualTo(new DateTime(expectedYear, 1, 1))); }
public void Run_parameters_CorrectResult(int count, int stepDay, int expected) { var strategy = new CountDateTimeLoopStrategy(count, new DateTime(2018, 1, 1), new FixedDuration(new TimeSpan(stepDay, 0, 0, 0))); var final = new DateTime(2018, 1, 1); while (strategy.IsOngoing()) { final = strategy.GetNext(); } Assert.That(final, Is.EqualTo(new DateTime(2018, 1, expected))); }
public void Execute_CountDateTime_ExactSequence() { var args = new CountDateTimeLoopStrategy(3, new DateTime(2018, 1, 30), new FixedDuration(new TimeSpan(1, 0, 0, 0))); var resolver = new LoopSequenceResolver <DateTime>(args); var elements = resolver.Execute(); Assert.That(elements.Count(), Is.EqualTo(3)); Assert.That(elements, Is.EqualTo(new List <DateTime>() { new DateTime(2018, 1, 30), new DateTime(2018, 1, 31), new DateTime(2018, 2, 1) })); }
public void IsOngoing_NTimes_True() { var strategy = new CountDateTimeLoopStrategy(10, new DateTime(2015, 1, 1), new FixedDuration(new TimeSpan(1, 0, 0, 0))); Assert.That(strategy.IsOngoing(), Is.True); }
public void GetNext_FirstTime_Seed() { var strategy = new CountDateTimeLoopStrategy(10, new DateTime(2018, 1, 1), new FixedDuration(new TimeSpan(1, 0, 0, 0))); Assert.That(strategy.GetNext(), Is.EqualTo(new DateTime(2018, 1, 1))); }