public async Task Should_not_call_for_one_other_event()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();
            await _machine.RaiseEvent(_instance, _machine.Start);

            await _machine.RaiseEvent(_instance, _machine.Second);

            Assert.IsFalse(_instance.Called);
        }
Пример #2
0
        public void Should_not_call_for_one_event()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();
            _machine.RaiseEvent(_instance, _machine.Start);

            _machine.RaiseEvent(_instance, _machine.First);

            Assert.IsFalse(_instance.Called);
        }
Пример #3
0
        public void Should_have_called_combined_event()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();
            _machine.RaiseEvent(_instance, _machine.Start);

            _machine.RaiseEvent(_instance, _machine.First);
            _machine.RaiseEvent(_instance, _machine.Second);

            Assert.IsTrue(_instance.Called);
        }
        public async Task Should_have_called_combined_event_after_all_events()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();
            await _machine.RaiseEvent(_instance, _machine.Start);

            await _machine.RaiseEvent(_instance, _machine.First);

            await _machine.RaiseEvent(_instance, _machine.Second);

            Assert.IsTrue(_instance.CalledAfterAll);
        }
        public async Task Should_skip_when_not_met()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();
            await _machine.RaiseEvent(_instance, _machine.Start);

            await _machine.RaiseEvent(_instance, _machine.First);

            await _machine.RaiseEvent(_instance, _machine.Second);

            Assert.IsFalse(_instance.Called);
            Assert.IsFalse(_instance.SecondFirst);
        }
Пример #6
0
        public void A_state_is_declared()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();

            _machine.RaiseEvent(_instance, x => x.Started).Wait();
        }
Пример #7
0
        public async Task Should_have_called_combined_event()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();
            await _machine.RaiseEvent(_instance, _machine.Start);

            Assert.IsFalse(_instance.Called);

            await _machine.RaiseEvent(_instance, _machine.First);

            await _machine.RaiseEvent(_instance, _machine.Second);

            Assert.IsTrue(_instance.Called);

            Assert.AreEqual(2, _instance.CurrentState);
        }
Пример #8
0
        public void A_state_is_declared()
        {
            _instance = new Instance();
            _machine  = new TestStateMachine();

            _machine.RaiseEvent(_instance, _machine.Hello);
        }
Пример #9
0
        public async Task Should_have_initial_state_with_zero()
        {
            _machine  = new TestStateMachine();
            _instance = new Instance();
            await _machine.RaiseEvent(_instance, _machine.Start);

            Assert.AreEqual(3, _instance.CurrentState);
        }
Пример #10
0
            public async void Should_property_initialize()
            {
                var machine  = new TestStateMachine();
                var instance = new TestState();

                var requestQuote = new RequestQuote
                {
                    Symbol       = "MSFT",
                    TicketNumber = "8675309",
                };

                ConsumeContext <RequestQuote> consumeContext = new InternalConsumeContext <RequestQuote>(requestQuote);

                await machine.RaiseEvent(instance, machine.QuoteRequested, requestQuote, consumeContext);

                await machine.RaiseEvent(instance, x => x.QuoteRequest.Completed, new Quote { Symbol = requestQuote.Symbol });
            }
Пример #11
0
        public async Task Should_capture_the_value()
        {
            var claim   = new TestInstance();
            var machine = new TestStateMachine();

            await machine.RaiseEvent(claim, machine.Create, new CreateInstance());

            Assert.AreEqual("ExecuteAsync", claim.Value);
        }
Пример #12
0
        protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
        {
            _machine    = new TestStateMachine();
            _repository = new InMemorySagaRepository <Instance>();

            configurator.StateMachineSaga(_machine, _repository, x =>
            {
                IPipe <ExceptionSagaConsumeContext <Instance> > rescuePipe = Pipe.New <ExceptionSagaConsumeContext <Instance> >(p =>
                {
                    p.UseExecuteAsync(async context =>
                    {
                        await _machine.RaiseEvent(context.Saga, e => e.InlineStartFaulted, new StartFault(context.Saga.CorrelationId));
                    });
                });
                x.UseRescue(rescuePipe);
            });
        }