Exemple #1
0
        public void IsOngoing_OneTimes_TrueThenFalse()
        {
            var strategy = new SentinelCloseDateTimeLoopStrategy(new DateTime(2018, 1, 1), new DateTime(2018, 1, 1), new FixedDuration(new TimeSpan(1, 0, 0, 0)));

            Assert.That(strategy.IsOngoing(), Is.True);
            strategy.GetNext();
            Assert.That(strategy.IsOngoing(), Is.False);
        }
Exemple #2
0
        public void Run_Year_CorrectResult(int stepMonth, int expected)
        {
            var strategy = new SentinelCloseDateTimeLoopStrategy(new DateTime(2018, 1, 1), new DateTime(2019, 4, 10), new YearDuration(stepMonth));
            var final    = DateTime.MinValue;

            while (strategy.IsOngoing())
            {
                final = strategy.GetNext();
            }
            Assert.That(final, Is.EqualTo(new DateTime(expected, 1, 1)));
        }
Exemple #3
0
        public void Run_day_CorrectResult(int stepDay, int expected)
        {
            var strategy = new SentinelCloseDateTimeLoopStrategy(new DateTime(2018, 1, 1), new DateTime(2018, 1, 5), 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)));
        }
Exemple #4
0
        public void Execute_SentinelDateTime_ExactSequence()
        {
            var args     = new SentinelCloseDateTimeLoopStrategy(new DateTime(2018, 1, 28), new DateTime(2018, 2, 2), new FixedDuration(new TimeSpan(2, 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, 28), new DateTime(2018, 1, 30), new DateTime(2018, 2, 1)
            }));
        }
Exemple #5
0
        public void IsOngoing_ZeroTimes_False()
        {
            var strategy = new SentinelCloseDateTimeLoopStrategy(new DateTime(2018, 1, 3), new DateTime(2018, 1, 2), new FixedDuration(new TimeSpan(1, 0, 0, 0)));

            Assert.That(strategy.IsOngoing(), Is.False);
        }
Exemple #6
0
        public void GetNext_FirstTime_Seed()
        {
            var strategy = new SentinelCloseDateTimeLoopStrategy(new DateTime(2018, 1, 1), new DateTime(2018, 1, 2), new FixedDuration(new TimeSpan(1, 0, 0, 0)));

            Assert.That(strategy.GetNext(), Is.EqualTo(new DateTime(2018, 1, 1)));
        }