Exemplo n.º 1
0
        public async Task Should_handle_the_stop_state()
        {
            Guid sagaId = Guid.NewGuid();

            SagaTest <IBusTestScenario, Instance> test = TestFactory.ForSaga <Instance>().New(x =>
            {
                x.UseStateMachineBuilder(_machine);

                x.Publish(new Start
                {
                    CorrelationId = sagaId
                });
                x.Publish(new Stop
                {
                    CorrelationId = sagaId
                });
            });

            await test.ExecuteAsync();

            Assert.IsTrue(test.Received.Select <Start>().Any(), "Start not received");
            Assert.IsTrue(test.Received.Select <Stop>().Any(), "Stop not received");

            Instance instance = test.Saga.Created.Contains(sagaId);

            Assert.IsNotNull(instance, "Saga instance not found");

            Assert.AreEqual(instance.CurrentState, _machine.Final);
        }
Exemplo n.º 2
0
        public void A_saga_is_being_tested()
        {
            _sagaId     = Guid.NewGuid();
            _testValueA = "TestValueA";

            _test = TestFactory.ForSaga <TestSaga>()
                    .New(x =>
            {
                x.Send(new A
                {
                    CorrelationId = _sagaId,
                    Value         = _testValueA
                });
            });

            _test.ExecuteAsync();
        }