Ejemplo n.º 1
0
        public void OnceAtDateTime()
        {
            // Arrange
            var now = DateTime.Now;
            var at  = new DateTime(2000, 10, 10, 10, 10, 10);

            var calculator = new TimeCalculator();
            var run        = new RunSpecifier(calculator);

            // Act
            run.OnceAt(at);
            var calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(at, calculated);

            // Act
            calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(null, calculated);
        }
Ejemplo n.º 2
0
        public void OnceAtAndEvery()
        {
            // Arrange
            var now = DateTime.Now;
            var at  = new DateTime(2000, 10, 10, 10, 10, 10);

            var calculator = new TimeCalculator();
            var run        = new RunSpecifier(calculator);

            // Act
            run.OnceAt(at).AndEvery(10).Seconds();
            var calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(at, calculated);

            // Act
            calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(now.AddSeconds(10), calculated);
        }
Ejemplo n.º 3
0
        public void OnceAtTimeSpan()
        {
            // Arrange
            var now = DateTime.Today;
            var at  = new TimeSpan(13, 50, 0);

            var calculator = new TimeCalculator();
            var run        = new RunSpecifier(calculator);

            // Act
            run.OnceAt(at);
            var calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(now.Add(at), calculated);

            // Act
            calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(null, calculated);
        }
Ejemplo n.º 4
0
        public void OnceAtHoursMinutes()
        {
            // Arrange
            var now     = DateTime.Today;
            var hours   = 13;
            var minutes = 50;

            var calculator = new TimeCalculator();
            var run        = new RunSpecifier(calculator);

            // Act
            run.OnceAt(hours, minutes);
            var calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(now.Date.AddHours(hours).AddMinutes(minutes), calculated);

            // Act
            calculated = calculator.Calculate(now);

            // Assert
            Assert.AreEqual(null, calculated);
        }