示例#1
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");
        }
示例#2
0
        public async Task TestHandleMultipleEventsInStateMachine()
        {
            var result = new Result();

            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M2>(configuration: configuration);

            await test.StartActorAsync(new SetupEvent(result));

            await test.SendEventAsync(new E1());

            await test.SendEventAsync(new E2());

            await test.SendEventAsync(new E3());

            test.AssertInboxSize(0);
            test.Assert(result.Value == 6, $"Incorrect result '{result.Value}'");
        }
示例#3
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);
        }
示例#4
0
        public async Task TestMultipleReceiveEventStatementsWithMultipleTypes()
        {
            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M4>(configuration: configuration);

            await test.StartActorAsync();

            test.AssertIsWaitingToReceiveEvent(true);

            await test.SendEventAsync(new E1());

            test.AssertIsWaitingToReceiveEvent(true);

            await test.SendEventAsync(new E2());

            test.AssertIsWaitingToReceiveEvent(true);

            await test.SendEventAsync(new E3());

            test.AssertIsWaitingToReceiveEvent(false);
            test.AssertInboxSize(0);
        }