public void TestRotateRight()
        {
            // 0111 1011
            var mask = 0x7F ^ 0x04;

            // 0111 1101
            var expectedResult = 0x7F ^ 0x02;
            var result         = BitmaskHelper.RotateRight(mask, 1, 7);

            Assert.That(result == expectedResult);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the NextExecution Date for this job
        /// </summary>
        /// <param name="runtime">The timestamp of the current execution</param>
        /// <returns>A DateTime for the next execution date, or null if the schedule is invalid</returns>
        public DateTime?GetNextExecution(DateTime runtime)
        {
            var runtimeMask  = BitmaskHelper.RotateRight(this.ExecutionSchedule, (int)runtime.DayOfWeek + 1, 7);
            var numberOfDays = 1;

            while (((runtimeMask & 1) == 0) && numberOfDays < 7)
            {
                numberOfDays++;
                runtimeMask = runtimeMask >> 1;
            }

            return(((runtimeMask & 1) == 0) ? default(DateTime?) : runtime.Date.AddDays(numberOfDays).Add(TimeOfDay(this.ExecutionTime)));
        }