コード例 #1
0
        public void When_ScheduleRepeatedly_using_canceled_Cancelable_Then_their_actions_should_not_be_invoked()
        {
            // Prepare, set up actions to be fired
            IActionScheduler scheduler = new DedicatedThreadScheduler(Sys.Settings.Config, Log);

            try
            {
                var canceled = Cancelable.CreateCanceled();
                scheduler.ScheduleRepeatedly(0, 100, () => TestActor.Tell("Test1"), canceled);
                scheduler.ScheduleRepeatedly(50, 100, () => TestActor.Tell("Test2"), canceled);

                //Validate that no messages were sent
                ExpectNoMsg(150);
            }
            finally
            {
                scheduler.AsInstanceOf <IDisposable>().Dispose();
            }
        }
コード例 #2
0
        public void When_ScheduleRepeatedly_and_then_canceling_before_they_occur_Then_their_actions_should_not_be_invoked()
        {
            // Prepare, set up actions to be fired
            IActionScheduler scheduler = new DedicatedThreadScheduler(Sys.Settings.Config, Log);

            try
            {
                var cancelable = new Cancelable(scheduler);
                scheduler.ScheduleRepeatedly(100, 2, () => TestActor.Tell("Test"), cancelable);
                cancelable.Cancel();

                //Validate that no messages were sent
                ExpectNoMsg(150);
            }
            finally
            {
                scheduler.AsInstanceOf <IDisposable>().Dispose();
            }
        }
コード例 #3
0
        public void When_canceling_existing_running_repeaters_by_scheduling_the_cancellation_ahead_of_time_Then_their_future_actions_should_not_be_invoked()
        {
            // Prepare, set up actions to be fired
            IActionScheduler scheduler = new DedicatedThreadScheduler(Sys.Settings.Config, Log);

            try
            {
                var cancelableOdd = new Cancelable(scheduler);
                scheduler.ScheduleRepeatedly(1, 150, () => TestActor.Tell("Test"), cancelableOdd);
                cancelableOdd.CancelAfter(50);

                //Expect one message
                ExpectMsg("Test");

                //Validate that no messages were sent
                ExpectNoMsg(200);
            }
            finally
            {
                scheduler.AsInstanceOf <IDisposable>().Dispose();
            }
        }