public void 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 }); }); test.Execute(); 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); }
public void A_state_machine_saga_is_being_tested() { systemId = Guid.NewGuid(); test = TestFactory.ForSaga<CustomerRegistrationSaga>() .InSingleBusScenario() .New(x => { x.UseScenarioBuilder(() => new CustomBusScenarioBuilder()); x.Send(new ClientSystemCreatedEvent { SystemId = systemId }); x.Send(new UserCreatedEvent { SystemId = systemId }); x.Send(new SettingsCreatedEvent { SystemId = systemId }); x.Send(new SystemActivatedEvent { SystemId = systemId }); }); test.Execute(); }
public void Setup() { _machine = new SuperShopper(); AutomatonymousStateUserType <SuperShopper> .SaveAsString(_machine); _sessionFactory = new SqlLiteSessionFactoryProvider(typeof(ShoppingChoreMap)).GetSessionFactory(); _repository = new NHibernateSagaRepository <ShoppingChore>(_sessionFactory); _stateMachineRepository = new AutomatonymousStateMachineSagaRepository <ShoppingChore>(_repository, x => false, Enumerable.Empty <StateMachineEventCorrelation <ShoppingChore> >()); _correlationId = NewId.NextGuid(); _test = TestFactory.ForSaga <ShoppingChore>().New(x => { x.UseStateMachineBuilder(_machine); x.UseSagaRepository(_stateMachineRepository); x.Publish(new GirlfriendYelling { CorrelationId = _correlationId }); x.Publish(new GotHitByACar { CorrelationId = _correlationId }); }); _test.Execute(); }
public void TestFixtureSetUp() { _server = new EmbeddedMongoDbServer(); var mongoClient = _server.Client; //var mongoClient = new MongoClient("mongodb://localhost:27017"); // requires an instance of mongodb running at localhost _db = mongoClient.GetServer().GetDatabase("MassTransit-SagaTest"); _machine = new SuperShopper(); _repository = new MongoDbAutomatonymousSagaRepository <ShoppingChore, SuperShopper>(_db, _machine); _correlationId = NewId.NextGuid(); _test = TestFactory.ForSaga <ShoppingChore>().New(x => { x.UseStateMachineBuilder(_machine); x.UseSagaRepository(_repository); x.Publish(new GirlfriendYelling { CorrelationId = _correlationId }); x.Publish(new GotHitByACar { CorrelationId = _correlationId }); }); _test.Execute(); }
public void Should_handle_the_initial_state() { Guid sagaId = Guid.NewGuid(); SagaTest <BusTestScenario, Instance> test = TestFactory.ForSaga <Instance>().New(x => { x.UseStateMachineBuilder(_machine, sm => { sm.Correlate(_machine.Stopped, (s, m) => s.CorrelationId == m.CorrelationId); }); x.Publish(new Start { CorrelationId = sagaId }); }); test.Execute(); Assert.IsTrue(test.Received.Any <Start>(), "Message not received"); Instance instance = test.Saga.Created.Contains(sagaId); Assert.IsNotNull(instance, "Saga instance not found"); Assert.AreEqual(instance.CurrentState, _machine.Running); }
public void A_state_machine_saga_is_being_tested() { systemId = Guid.NewGuid(); test = TestFactory.ForSaga <CustomerRegistrationSaga>() .InSingleBusScenario() .New(x => { x.UseScenarioBuilder(() => new CustomBusScenarioBuilder()); x.Send(new ClientSystemCreatedEvent { SystemId = systemId }); x.Send(new UserCreatedEvent { SystemId = systemId }); x.Send(new SettingsCreatedEvent { SystemId = systemId }); x.Send(new SystemActivatedEvent { SystemId = systemId }); }); test.Execute(); }
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.Execute(); }
public void A_state_machine_saga_is_being_tested() { _sagaId = Guid.NewGuid(); _testValueA = "TestValueA"; _test = TestFactory.ForSaga <TestSaga>() .InSingleBusScenario() .New(x => { x.Send(new A { CorrelationId = _sagaId, Value = _testValueA }); x.Send(new B { CorrelationId = _sagaId, }); }); _test.Execute(); }
public void Initialize() { _test = TestFactory .ForSaga <TSaga>() .InSingleBusScenario() .New(sagaConfigurator => { var sagas = Given(); var sagaRepository = new InMemorySagaRepository <TSaga>(); foreach (var saga in sagas) { sagaRepository.Add(saga); } sagaConfigurator.UseSagaRepository(sagaRepository); When(sagaConfigurator); }); _test.Execute(); }
public void Setup() { _machine = new SuperShopper(); _sessionFactory = new SqlLiteSessionFactoryProvider(typeof(ShoppingChoreMap)).GetSessionFactory(); _repository = new NHibernateSagaRepository <ShoppingChore>(_sessionFactory); _stateMachineRepository = new AutomatonymousStateMachineSagaRepository <ShoppingChore>(_repository, x => x.CurrentState == _machine.Final, new StateMachineEventCorrelation <ShoppingChore>[] {}); _test = TestFactory.ForSaga <ShoppingChore>().New(x => { x.UseStateMachineBuilder(_machine); x.UseSagaRepository(_stateMachineRepository); x.Publish(new GirlfriendYelling { CorrelationId = NewId.NextGuid() }); }); _test.Execute(); }