Ejemplo n.º 1
0
        public void WindowScheduleCompareToEqual()
        {
            var t1 = TriggerWindow.Parse("10:22-12:22");
            var t2 = TriggerWindow.Parse("10:22-12:22");

            Assert.AreEqual(0, t1.CompareTo(t2));
        }
Ejemplo n.º 2
0
        public void WindowScheduleTriggerParse()
        {
            var t = TriggerWindow.Parse("10:22-12:22");

            Assert.AreEqual(new TimeSpan(0, 10, 22, 0), t.Start);
            Assert.AreEqual(new TimeSpan(0, 12, 22, 0), t.End);
            Assert.AreEqual(TimeSpan.FromHours(2), t.Window);
        }
Ejemplo n.º 3
0
        public void PointScheduleTriggerParse()
        {
            var t = TriggerWindow.Parse("10:22");

            Assert.AreEqual(new TimeSpan(0, 10, 22, 0), t.Start);
            Assert.AreEqual(new TimeSpan(0, 10, 22, 0), t.End);
            Assert.AreEqual(TimeSpan.Zero, t.Window);
        }
Ejemplo n.º 4
0
        public void WindowScheduleCompareToDifferent()
        {
            var t1 = TriggerWindow.Parse("10:22-12:22");
            var t2 = TriggerWindow.Parse("10:23-12:23");

            Assert.LessOrEqual(t1.CompareTo(t2), 0);
            Assert.GreaterOrEqual(t2.CompareTo(t1), 0);
        }
Ejemplo n.º 5
0
        public void NextSchedulePointExpirationExpireWindow()
        {
            var t = TriggerWindow.Parse("10:22");

            var reference = new DateTime(1986, 4, 18, 10, 22, 0);
            var after     = reference.AddDays(30);

            var nextTriggerTime = t.GetNextTriggerTime(reference, after, true, null);

            Assert.AreEqual(TimeSpan.FromDays(31), nextTriggerTime.ReferenceTillTrigger);
            Assert.AreEqual(null, nextTriggerTime.Expiration);
        }
Ejemplo n.º 6
0
        public void NextSchedulePointExpirationExpireWindow()
        {
            var t = TriggerWindow.Parse("10:22");

            var from  = new DateTime(1986, 4, 18, 10, 22, 0);
            var after = from.AddDays(30);

            var nextTriggerTime = t.GetNextTriggerTime(from, after, true, null);

            Assert.AreEqual(TimeSpan.FromDays(31), nextTriggerTime.TimeTill);
            Assert.AreEqual(DateTime.MaxValue, nextTriggerTime.Expiration);
        }
Ejemplo n.º 7
0
        public void NextSchedulePointNoExpiration()
        {
            var t = TriggerWindow.Parse("10:22");

            var reference = new DateTime(1986, 4, 18, 10, 22, 0);
            var after     = new DateTime(1986, 4, 25, 10, 22, 0);

            for (var i = 0; i < 100; i++)
            {
                var nextTriggerTime = t.GetNextTriggerTime(reference, after, false, null);

                Assert.AreEqual(TimeSpan.FromDays(8), nextTriggerTime.ReferenceTillTrigger);
                Assert.AreEqual(null, nextTriggerTime.Expiration);
            }
        }
Ejemplo n.º 8
0
        public void NextScheduleWindowWithExpireWindow()
        {
            var t = TriggerWindow.Parse("10:22-12:22");

            var reference = new DateTime(1986, 4, 18, 10, 22, 0);
            var after     = new DateTime(1986, 4, 25, 10, 22, 0);

            for (var i = 0; i < 100; i++)
            {
                var nextTriggerTime = t.GetNextTriggerTime(reference, after, true, null);

                Assert.GreaterOrEqual(nextTriggerTime.ReferenceTillTrigger, TimeSpan.FromDays(8));
                Assert.LessOrEqual(nextTriggerTime.ReferenceTillTrigger, TimeSpan.FromDays(8).Add(TimeSpan.FromHours(2)));
                Assert.AreEqual(reference.AddDays(8).AddHours(2), nextTriggerTime.Expiration);
            }
        }
Ejemplo n.º 9
0
        public void NextScheduleWindowNoExpiration()
        {
            var t = TriggerWindow.Parse("10:22-12:22");

            var from  = new DateTime(1986, 4, 18, 10, 22, 0);
            var after = new DateTime(1986, 4, 25, 10, 22, 0);

            for (var i = 0; i < 100; i++)
            {
                var nextTriggerTime = t.GetNextTriggerTime(from, after, false, null);

                Assert.GreaterOrEqual(nextTriggerTime.TimeTill, TimeSpan.FromDays(8));
                Assert.LessOrEqual(nextTriggerTime.TimeTill, TimeSpan.FromDays(8).Add(TimeSpan.FromHours(2)));
                Assert.AreEqual(DateTime.MaxValue, nextTriggerTime.Expiration);
            }
        }
Ejemplo n.º 10
0
        public void NextScheduleWindowWithExpirationTime()
        {
            var t = TriggerWindow.Parse("10:22-12:22");

            var reference = new DateTime(1986, 4, 18, 10, 22, 0);
            var after     = new DateTime(1986, 4, 25, 10, 22, 0);
            var expire    = TimeSpan.FromMinutes(1);

            for (var i = 0; i < 100; i++)
            {
                var nextTriggerTime = t.GetNextTriggerTime(reference, after, false, expire);

                Assert.GreaterOrEqual(nextTriggerTime.ReferenceTillTrigger, TimeSpan.FromDays(8));
                Assert.LessOrEqual(nextTriggerTime.ReferenceTillTrigger, TimeSpan.FromDays(8).Add(TimeSpan.FromHours(2)));
                Assert.That(nextTriggerTime.Expiration, Is.EqualTo(reference + nextTriggerTime.ReferenceTillTrigger + expire).Within(TimeSpan.FromSeconds(1)));
            }
        }
Ejemplo n.º 11
0
        public void NextScheduleWindowExpireAge()
        {
            var t = TriggerWindow.Parse("10:22-12:22");

            var reference = new DateTime(1986, 4, 18, 10, 22, 0);
            var after     = new DateTime(1986, 4, 25, 10, 22, 0);
            var expir     = TimeSpan.FromMinutes(10);

            for (var i = 0; i < 100; i++)
            {
                var nextTriggerTime = t.GetNextTriggerTime(reference, after, false, expir);

                Assert.GreaterOrEqual(nextTriggerTime.ReferenceTillTrigger, TimeSpan.FromDays(8));
                Assert.LessOrEqual(nextTriggerTime.ReferenceTillTrigger, TimeSpan.FromDays(8).Add(TimeSpan.FromHours(2)));
                Assert.AreEqual(reference + nextTriggerTime.ReferenceTillTrigger + expir, nextTriggerTime.Expiration);
            }
        }
Ejemplo n.º 12
0
        public void NextScheduleWindowMinExpiration()
        {
            var t = TriggerWindow.Parse("10:22-12:22");

            var from  = new DateTime(1986, 4, 18, 10, 22, 0);
            var after = new DateTime(1986, 4, 25, 10, 22, 0);
            var expir = TimeSpan.FromMinutes(1);

            for (var i = 0; i < 100; i++)
            {
                var nextTriggerTime = t.GetNextTriggerTime(from, after, true, expir);

                Assert.GreaterOrEqual(nextTriggerTime.TimeTill, TimeSpan.FromDays(8));
                Assert.LessOrEqual(nextTriggerTime.TimeTill, TimeSpan.FromDays(8).Add(TimeSpan.FromHours(2)));
                Assert.AreEqual(from + nextTriggerTime.TimeTill + expir, nextTriggerTime.Expiration);
            }
        }
Ejemplo n.º 13
0
        public void WindowScheduleToString()
        {
            var t = TriggerWindow.Parse("10:22-12:22");

            Assert.AreEqual("10:22-12:22", t.ToString());
        }