Example #1
0
        public async Task TestGotoStateTransitionAfterRaise()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M3>(configuration: configuration);
            await test.StartMachineAsync();

            test.AssertStateTransition("Final");
        }
Example #2
0
        public async Task TestInvokeInternalAsyncMethod()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M2>(configuration: configuration);

            int result = await test.Machine.AddAsync(3, 4);

            test.Assert(result == 7, $"Incorrect result '{result}'");
        }
Example #3
0
        public void TestInvokeInternalMethod()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M1>(configuration: configuration);

            int result = test.Machine.Add(3, 4);

            test.Assert(result == 7, $"Incorrect result '{result}'");
        }
Example #4
0
        public void TestInvokePrivateMethod()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M3>(configuration: configuration);

            int result = (int)test.Invoke("Add", 3, 4);

            test.Assert(result == 7, $"Incorrect result '{result}'");

            result = (int)test.Invoke("Add", new Type[] { typeof(int), typeof(int) }, 3, 4);
            test.Assert(result == 7, $"Incorrect result '{result}'");
        }
Example #5
0
        public async Task TestGotoStateTransitionAfterSend()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M2>(configuration: configuration);
            await test.StartMachineAsync();

            test.AssertStateTransition("Init");

            await test.SendEventAsync(new Message());

            test.AssertStateTransition("Final");
        }
Example #6
0
        public async Task TestInvokePrivateAsyncMethod()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M4>(configuration: configuration);

            int result = (int)await test.InvokeAsync("AddAsync", 3, 4);

            test.Assert(result == 7, $"Incorrect result '{result}'");

            result = (int)await test.InvokeAsync("AddAsync", new Type[] { typeof(int), typeof(int) }, 3, 4);

            test.Assert(result == 7, $"Incorrect result '{result}'");
        }
        public async Task TestReceiveEventStatement()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M1>(configuration: configuration);

            await test.StartMachineAsync();

            test.AssertIsWaitingToReceiveEvent(true);

            await test.SendEventAsync(new E1());

            test.AssertIsWaitingToReceiveEvent(false);
            test.AssertInboxSize(0);
        }
Example #8
0
        public async Task TestHandleEvent()
        {
            var result = new Result();

            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M1>(configuration: configuration);

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

            await test.SendEventAsync(new E1());

            test.AssertInboxSize(0);
            test.Assert(result.Value == 1, $"Incorrect result '{result.Value}'");
        }
        public async Task TestMultipleReceiveEventStatementsUnordered()
        {
            var configuration = GetConfiguration();
            var test          = new MachineTestKit <M2>(configuration: configuration);

            await test.StartMachineAsync();

            test.AssertIsWaitingToReceiveEvent(true);

            await test.SendEventAsync(new E2());

            test.AssertIsWaitingToReceiveEvent(true);
            test.AssertInboxSize(1);

            await test.SendEventAsync(new E3());

            test.AssertIsWaitingToReceiveEvent(true);
            test.AssertInboxSize(2);

            await test.SendEventAsync(new E1());

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