コード例 #1
0
        public void WhenAddMultipleActionsWithDifferentDelays_ShouldExecuteInRightOrder()
        {
            var testee  = new ApplicationDispatcher();
            var action1 = new ActionTester();
            var action2 = new ActionTester();

            testee.AddDelayedAction(-1, action1.TestAction);
            testee.AddDelayedAction(5, action2.TestAction);

            testee.ExecuteInvokes();
            action1.WasCalled.Should().BeTrue();
            action2.WasCalled.Should().BeFalse();

            Thread.Sleep(25);
            testee.ExecuteInvokes();
            action2.WasCalled.Should().BeTrue();
        }
コード例 #2
0
        public void WhenAddNegativeDelayedAction_ShouldExecuteImmediately()
        {
            var testee       = new ApplicationDispatcher();
            var actionTester = new ActionTester();

            testee.AddDelayedAction(-10, actionTester.TestAction);
            testee.ExecuteInvokes();

            actionTester.WasCalled.Should().BeTrue();
        }
コード例 #3
0
        public void WhenClearActions_ShouldExecuteNothing()
        {
            var testee       = new ApplicationDispatcher();
            var actionTester = new ActionTester();

            testee.AddDelayedAction(5, actionTester.TestAction);
            testee.AddActionAfterPolls(1, actionTester.TestAction);

            testee.CancellAll();
            Thread.Sleep(25);
            testee.ExecuteInvokes();

            actionTester.WasCalled.Should().BeFalse();
        }
コード例 #4
0
        public void WhenAddDelayedAction_ShouldExecuteDelayed()
        {
            var testee       = new ApplicationDispatcher();
            var actionTester = new ActionTester();

            testee.AddDelayedAction(20, actionTester.TestAction);
            testee.ExecuteInvokes();

            actionTester.WasCalled.Should().BeFalse();

            Thread.Sleep(25);
            testee.ExecuteInvokes();

            actionTester.WasCalled.Should().BeTrue();
        }
コード例 #5
0
        public void WhenAddMixedActions_AfterPoll_ShouldExecuteAll()
        {
            var testee = new ApplicationDispatcher();

            var action1 = new ActionTester();
            var action2 = new ActionTester();

            testee.AddDelayedAction(-1, action1.TestAction);
            testee.AddActionAfterPolls(1, action2.TestAction);

            testee.ExecuteInvokes();

            action1.WasCalled.Should().BeTrue();
            action2.WasCalled.Should().BeTrue();
        }