private void AssertParse(
            string text,
            long?expectedNumRepeats,
            string expectedDate,
            TimePeriod expectedTimePeriod)
        {
            var spec = TimerScheduleISO8601Parser.Parse(text);

            Assert.AreEqual(expectedNumRepeats, spec.OptionalRepeatCount);
            if (expectedTimePeriod == null)
            {
                Assert.IsNull(spec.OptionalTimePeriod);
            }
            else
            {
                Assert.AreEqual(
                    expectedTimePeriod,
                    spec.OptionalTimePeriod,
                    "expected '" + expectedTimePeriod.ToStringISO8601() + "' got '" + spec.OptionalTimePeriod.ToStringISO8601() + "'");
            }

            if (expectedDate == null)
            {
                Assert.IsNull(spec.OptionalDate);
            }
            else
            {
                Assert.AreEqual(DateTimeParsingFunctions.ParseDefaultMSecWZone(expectedDate), spec.OptionalDate.UtcMillis);
            }
        }
예제 #2
0
        public void CheckCorrectWZone(
            ScheduleSpec spec,
            string nowWZone,
            string expectedWZone)
        {
            var nowDate      = DateTimeParsingFunctions.ParseDefaultMSecWZone(nowWZone);
            var expectedDate = DateTimeParsingFunctions.ParseDefaultMSecWZone(expectedWZone);

            var result = ScheduleComputeHelper.ComputeNextOccurance(
                spec, nowDate,
                TimeZoneInfo.Utc,
                TimeAbacusMilliseconds.INSTANCE);
            var resultDate = DateTimeEx.GetInstance(TimeZoneInfo.Utc, result);

            if (result != expectedDate)
            {
                Log.Debug(
                    ".checkCorrect Difference in result found, spec=" + spec);
                Log.Debug(
                    ".checkCorrect now=" + timeFormat.Format(nowDate.TimeFromMillis()) +
                    " long=" + nowDate);
                Log.Debug(
                    ".checkCorrect expected=" + timeFormat.Format(expectedDate.TimeFromMillis()) +
                    " long=" + expectedDate);
                Log.Debug(
                    ".checkCorrect result=" + timeFormat.Format(resultDate) +
                    " long=" + resultDate.UtcMillis);
                Assert.IsTrue(false);
            }
        }
 public static DateTimeEx GetThe1980Calendar()
 {
     var dateTimeEx = DateTimeEx.GetInstance(
         TimeZoneHelper.GetTimeZoneInfo("GMT-0:00"),
         DateTimeParsingFunctions.ParseDefaultMSecWZone("1980-01-01T00:0:0.000GMT-0:00"));
     return dateTimeEx;
 }
        private static void AssertReceivedAtTime(
            RegressionEnvironment env,
            string time)
        {
            var msec = DateTimeParsingFunctions.ParseDefaultMSecWZone(time);

            env.AdvanceTime(msec - 1);
            Assert.IsFalse(env.Listener("s0").IsInvokedAndReset());

            env.AdvanceTime(msec);
            Assert.IsTrue(env.Listener("s0").IsInvokedAndReset(), "expected but not received at " + time);
        }
 private static void SendTimeEventWithZone(
     RegressionEnvironment env,
     string time)
 {
     env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSecWZone(time));
 }