コード例 #1
0
        public async Task TestGotoStateTransitionAfterSend()
        {
            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M2>(configuration: configuration);
            await test.StartActorAsync();

            test.AssertStateTransition("Init");

            await test.SendEventAsync(new Message());

            test.AssertStateTransition("Final");
        }
コード例 #2
0
        public async Task TestGotoStateTransitionAfterRaise()
        {
            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M3>(configuration: configuration);
            await test.StartActorAsync();

            test.AssertStateTransition("Final");
        }
コード例 #3
0
        public async Task TestPushPopTransition()
        {
            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M4>(configuration: configuration);
            await test.StartActorAsync();

            await test.SendEventAsync(new E1());

            await test.SendEventAsync(new E2());

            test.AssertStateTransition("Init");
            test.Assert(test.ActorInstance.Count == 1, "Did not reach Final state");
        }
コード例 #4
0
        public async Task TestInheritedDuplicateDeferHandler()
        {
            // inherited state can re-define a DeferEvent, IgnoreEvent or a Goto if it wants to, this is not an error.
            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M9>(configuration: configuration);
            await test.StartActorAsync();

            await test.SendEventAsync(new E1()); // should be deferred

            await test.SendEventAsync(new E2()); // should be ignored

            await test.SendEventAsync(new E3()); // should trigger goto, where deferred E1 can be handled.

            test.AssertStateTransition("Final");
        }
コード例 #5
0
        public async Task TestPushStateInheritance()
        {
            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M5>(configuration: configuration);
            await test.StartActorAsync();

            await test.SendEventAsync(new E2()); // should be deferred

            await test.SendEventAsync(new E1()); // push

            await test.SendEventAsync(new E3()); // ignored

            await test.SendEventAsync(new E4()); // inherited handler

            test.AssertStateTransition("Final");
            string actual   = string.Join(", ", test.ActorInstance.Log);
            string expected = "E2 in state Final, E4 in state Final";

            Assert.Equal(expected, actual);
        }