예제 #1
0
 public void JustHourNotInclusive()
 {
     var expected = new DateTime(2016, 2, 10, 9, 0, 0);
     var from = new DateTime(2016, 2, 10, 8, 15, 30);
     var sut = new Hour { };
     Assert.AreEqual(expected, sut.Evaluate(from, false));
 }
예제 #2
0
 public void JustHourInclusiveExactSameTime()
 {
     var expected = new DateTime(2016, 2, 10, 9, 0, 0);
     var from = new DateTime(2016, 2, 10, 9, 0, 0);
     var sut = new Hour { };
     Assert.AreEqual(expected, sut.Evaluate(from, true));
 }
예제 #3
0
 public void HourWithOffsetInMinutesAndSecondsFromBefore()
 {
     var expected = new DateTime(2016, 2, 10, 8, 15, 30);
     var from = new DateTime(2016, 2, 10, 8, 15, 29);
     var sut = new Hour { OffsetInSeconds = (15 * 60) + 30 };
     Assert.AreEqual(expected, sut.Evaluate(from));
 }
예제 #4
0
 public void HourWithOffsetInMinutesAndSecondsExactlySameTimeNotInclusive()
 {
     var expected = new DateTime(2016, 2, 10, 9, 15, 30);
     var from = new DateTime(2016, 2, 10, 8, 15, 30);
     var sut = new Hour { OffsetInSeconds = (15 * 60) + 30 };
     Assert.AreEqual(expected, sut.Evaluate(from, false));
 }
예제 #5
0
 internal override OperatorBuilder InternalBuild()
 {
     var hour = new Hour { OffsetInSeconds = _offset };
     return new OperatorBuilder(constraints =>
         {
             hour.AddConstraints(constraints);
             return hour;
         });
 }
        public override void ExitEveryhour(GoldenFoxLanguageParser.EveryhourContext context)
        {
            if (!Current.SecondsOffset.Any())
            {
                Current.SecondsOffset.Push(0);
            }

            var constraints = new List<IConstraint>();
            while (Current.Constraints.Any())
            {
                constraints.Add(Current.Constraints.Pop());
            }

            while (Current.SecondsOffset.Any())
            {

                var hour = new Hour { OffsetInSeconds = Current.SecondsOffset.Pop() };
                if (constraints.Any())
                {
                    hour.AddConstraints(constraints);
                }

                _stack.Push(hour);
            }
        }