Exemple #1
0
        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();
        }
        protected override void ConfigureLifetimeScope(ContainerBuilder builder)
        {
            builder.Register(CreateImageRetrievalSessionFactory)
            .SingleInstance();

            builder.RegisterType <NHibernateSagaRepository <ImageRetrievalState> >()
            .As <ISagaRepository <ImageRetrievalState> >()
            .SingleInstance();

            builder.RegisterType <AutofacStateMachineActivityFactory>()
            .As <IStateMachineActivityFactory>()
            .InstancePerLifetimeScope();

            builder.RegisterType <SendRetrieveImageCommandConfigurationSettings>()
            .As <SendRetrieveImageCommandSettings>()
            .SingleInstance();

            builder.RegisterType <SendRetrieveImageCommandActivity>();

            builder.Register(context =>
            {
                var stateMachineActivityFactory = context.Resolve <IStateMachineActivityFactory>();
                var machine = new ImageRetrievalStateMachine(stateMachineActivityFactory);

                AutomatonymousStateUserType <ImageRetrievalStateMachine> .SaveAsString(machine);

                return(machine);
            }).SingleInstance();

            builder.RegisterType <ImageRetrievalStateBusInstance>()
            .As <IServiceBusInstance>();

            base.ConfigureLifetimeScope(builder);
        }
Exemple #3
0
        public void Setup()
        {
            _machine = new SuperShopper();
            AutomatonymousStateUserType <SuperShopper> .SaveAsString(_machine);

            _sessionFactory = new SQLiteSessionFactoryProvider(typeof(ShoppingChoreMap))
                              .GetSessionFactory();
        }
        public static void StateProperty <T, TMachine>(this IClassMapper <T> mapper,
                                                       Expression <Func <T, State> > stateExpression, TMachine machine, State[] statesInOrder)
            where T : class
            where TMachine : StateMachine, new()
        {
            AutomatonymousStateUserType <TMachine> .SaveAsInt32(machine, statesInOrder);

            mapper.Property(stateExpression, x =>
            {
                x.Type <AutomatonymousStateUserType <TMachine> >();
                x.NotNullable(true);
                x.Length(80);
            });
        }