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 });
            }
Esempio n. 2
0
            public async Task Should_property_initialize()
            {
                Request <GetQuote, Quote> QuoteRequest   = null;
                Event <RequestQuote>      QuoteRequested = null;

                var machine = AutomatonymousStateMachine <TestState>
                              .New(builder => builder
                                   .InstanceState(x => x.CurrentState)
                                   .Event("QuoteRequested", out QuoteRequested)
                                   .Request(x => x.ServiceAddress = new Uri("loopback://localhost/my_queue"), "QuoteRequest", out QuoteRequest)
                                   .Initially()
                                   .When(QuoteRequested, b => b
                                         .Then(context => Console.WriteLine("Quote requested: {0}", context.Data.Symbol))
                                         .Request(QuoteRequest, context => new GetQuote {
                    Symbol = context.Message.Symbol
                })
                                         .TransitionTo(QuoteRequest.Pending)
                                         )
                                   .During(QuoteRequest.Pending)
                                   .When(QuoteRequest.Completed, b => b.Then((context) => Console.WriteLine("Request Completed!")))
                                   .When(QuoteRequest.Faulted, b => b.Then((context) => Console.WriteLine("Request Faulted")))
                                   .When(QuoteRequest.TimeoutExpired, b => b.Then((context) => Console.WriteLine("Request timed out")))
                                   );

                var instance = new TestState();

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

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

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

                await machine.RaiseEvent(instance, QuoteRequest.Completed, new Quote { Symbol = requestQuote.Symbol });
            }