Пример #1
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");
        }
Пример #2
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");
        }
Пример #3
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}'");
        }
Пример #4
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);
        }
Пример #5
0
        public async Task TestClassEventHandlerWildcardOverride()
        {
            var configuration = GetConfiguration();
            var test          = new ActorTestKit <M3>(configuration: configuration);

            await test.StartActorAsync();

            await test.SendEventAsync(new E1());

            test.Assert(test.ActorInstance.Count == 1, "HandleWildCard was not called");
        }
        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");
        }
Пример #7
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);
        }