public void When_ScheduleTellOnce_many_at_the_same_time_Then_all_fires(int[] times) { // Prepare, set up actions to be fired IScheduler scheduler = new HashedWheelTimerScheduler(Sys.Settings.Config, Log); try { foreach (var time in times) { scheduler.ScheduleTellOnce(time, TestActor, "Test" + time, ActorRefs.NoSender); } //Perform the test ExpectMsg("Test1"); ExpectMsg("Test1"); ExpectMsg("Test50"); ExpectMsg("Test50"); ExpectMsg("Test100"); ExpectMsg("Test100"); ExpectNoMsg(50); } finally { scheduler.AsInstanceOf <IDisposable>().Dispose(); } }
public void When_ScheduleTellOnce_using_canceled_Cancelable_Then_their_actions_should_not_be_invoked() { // Prepare, set up actions to be fired ITellScheduler scheduler = new HashedWheelTimerScheduler(Sys.Settings.Config, Log); try { var canceled = Cancelable.CreateCanceled(); scheduler.ScheduleTellOnce(0, TestActor, "Test", ActorRefs.NoSender, canceled); scheduler.ScheduleTellOnce(1, TestActor, "Test", ActorRefs.NoSender, canceled); //Validate that no messages were sent ExpectNoMsg(100); } finally { scheduler.AsInstanceOf <IDisposable>().Dispose(); } }
public void When_ScheduleTellOnce_with_0_delay_Then_action_is_executed_immediately() { IScheduler scheduler = new HashedWheelTimerScheduler(Sys.Settings.Config, Log); try { scheduler.ScheduleTellOnce(0, TestActor, "Test", ActorRefs.NoSender); ExpectMsg("Test"); } finally { scheduler.AsInstanceOf <IDisposable>().Dispose(); } }
public void When_ScheduleTellOnce_with_invalid_delay_Then_exception_is_thrown(int invalidTime) { IScheduler scheduler = new HashedWheelTimerScheduler(Sys.Settings.Config, Log); try { XAssert.Throws <ArgumentOutOfRangeException>(() => scheduler.ScheduleTellOnce(invalidTime, TestActor, "Test", ActorRefs.NoSender) ); ExpectNoMsg(50); } finally { scheduler.AsInstanceOf <IDisposable>().Dispose(); } }
public void When_ScheduleTellOnce_and_then_canceling_before_they_occur_Then_their_actions_should_not_be_invoked() { // Prepare, set up actions to be fired IScheduler scheduler = new HashedWheelTimerScheduler(Sys.Settings.Config, Log); try { var cancelable = new Cancelable(scheduler); scheduler.ScheduleTellOnce(100, TestActor, "Test", ActorRefs.NoSender, cancelable); cancelable.Cancel(); //Validate that no messages were sent ExpectNoMsg(150); } finally { scheduler.AsInstanceOf <IDisposable>().Dispose(); } }
public void ScheduleTellOnceTests(int[] times) { // Prepare, set up messages to be sent IScheduler scheduler = new HashedWheelTimerScheduler(Sys.Settings.Config, Log); try { foreach (var time in times) { scheduler.ScheduleTellOnce(time, TestActor, "Test" + time, ActorRefs.NoSender); } ExpectMsg("Test1"); ExpectMsg("Test50"); ExpectMsg("Test110"); ExpectNoMsg(50); } finally { scheduler.AsInstanceOf <IDisposable>().Dispose(); } }