public void When_ScheduleTellOnce_using_canceled_Cancelable_Then_their_actions_should_not_be_invoked()
        {
            // Prepare, set up actions to be fired
            ITellScheduler scheduler = new DedicatedThreadScheduler(Sys);

            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);
        }
        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 DedicatedThreadScheduler(Sys);

            var cancelable = new Cancelable(scheduler);
            scheduler.ScheduleTellOnce(100, TestActor, "Test", ActorRefs.NoSender, cancelable);
            cancelable.Cancel();

            //Validate that no messages were sent
            ExpectNoMsg(150);
        }
        public void ScheduleTellOnceTests(int[] times)
        {
            // Prepare, set up messages to be sent
            IScheduler scheduler = new DedicatedThreadScheduler(Sys);

            foreach(var time in times)
            {
                scheduler.ScheduleTellOnce(time, TestActor, "Test" + time, ActorRefs.NoSender);
            }

            ExpectMsg("Test1");
            ExpectMsg("Test50");
            ExpectMsg("Test110");

            ExpectNoMsg(50);
        }
 public void When_ScheduleTellOnce_with_0_delay_Then_action_is_executed_immediately()
 {
     IScheduler scheduler = new DedicatedThreadScheduler(Sys);
     scheduler.ScheduleTellOnce(0, TestActor, "Test", ActorRefs.NoSender);
     ExpectMsg("Test");
 }
        public void When_ScheduleTellOnce_with_invalid_delay_Then_exception_is_thrown(int invalidTime)
        {
            IScheduler scheduler = new DedicatedThreadScheduler(Sys);

            XAssert.Throws<ArgumentOutOfRangeException>(() =>
                scheduler.ScheduleTellOnce(invalidTime, TestActor, "Test", ActorRefs.NoSender)
                );
            ExpectNoMsg(50);
        }
        public void When_ScheduleTellOnce_many_at_the_same_time_Then_all_fires(int[] times)
        {
            // Prepare, set up actions to be fired
            IScheduler scheduler = new DedicatedThreadScheduler(Sys);

            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);
        }