Exemplo n.º 1
0
        public void ChangeState_GivenPartialSync_WhereBehaviorIsNotAsync_DoBehaviorIsNotAsync()
        {
            var uut     = StateMachineFactory.Create <DummyState>("Demo StateMachine", _logger);
            var harness = new StateMachineTestHarness <DummyState>(uut, DummyState.One.ToString());

            TestBuilder.BuildOneWayMachineWithTriggers(harness.Machine, harness);

            Assert.IsFalse(harness.WaitUntilAsyncDoBehavior(TimeSpan.FromSeconds(1)), "DO behavior executed asynchronously.");
        }
Exemplo n.º 2
0
        public void ChangeState_GivenPartialSync_WhereBehaviorIsAsync_DoBehaviorIsAsync()
        {
            var uut     = Behavioral.StateMachineFactory.CreateBehaviorAsync <DummyState>("Demo StateMachine", _logger);
            var harness = new StateMachineTestHarness <DummyState>(uut, DummyState.One.ToString());

            TestBuilder.BuildOneWayMachineWithTriggers(harness.Machine, harness);

            // The DO behavior should be able to complete its work independent of the current waiting thread.
            Assert.IsTrue(harness.WaitUntilAsyncDoBehavior(TimeSpan.FromSeconds(1)), "Waited too long for DO behavior execution.");
        }
Exemplo n.º 3
0
        public void ChangeState_GivenPartialAsync_DoBehaviorIsNotAsync()
        {
            var uut     = Behavioral.StateMachineFactory.CreateTriggerAsync <DummyState>("Demo StateMachine", _logger);
            var harness = new StateMachineTestHarness <DummyState>(uut, DummyState.One.ToString());

            TestBuilder.BuildOneWayMachineWithTriggers(harness.Machine, harness);

            // The DO behavior should be blocked from completing its work because the current thread is on the transition,
            // which is waiting on the DO behavior.
            Assert.IsFalse(harness.WaitUntilAsyncDoBehavior(TimeSpan.FromSeconds(1)), "DO behavior executed asynchronously.");
        }