Beispiel #1
0
 private static ICommandService InitCommandService()
 {
     var service = new CommandService();
     service.RegisterExecutorsInAssembly(typeof(CreateInvoicePayment).Assembly);
     service.AddInterceptor(new ThrowOnExceptionInterceptor());
     return service;
 }
Beispiel #2
0
 public Configuration(SetValidationCommandInterceptor interceptor)
 {
     var commandService = new CommandService();
     commandService.Configure();
     commandService.AddInterceptor(interceptor);
     Register<ICommandService>(commandService);
 }
        private static ICommandService InitializeCommandService()
        {
            var commandAssembly = typeof(CreateNewNote).Assembly;
            var service = new CommandService();

            service.RegisterExecutorsInAssembly(commandAssembly);
            service.AddInterceptor(new ThrowOnExceptionInterceptor());

            return service;
        }
Beispiel #4
0
        private static ICommandService InitCommandService()
        {
            var service = new CommandService();

            service.RegisterExecutorsInAssembly(typeof(CreateInvoice).Assembly);
            service.RegisterExecutor(new CreateInvoiceService());
            service.RegisterExecutor(new AddInvoiceItemService());
            service.AddInterceptor(new ThrowOnExceptionInterceptor());
            return(service);
        }
Beispiel #5
0
        public CommandServiceBaseTests()
        {
            var service = new CommandService();
            ExecutorForCommandWithExecutor = MockRepository.GenerateMock<ICommandExecutor<CommandWithExecutor>>();
            ExecutorForCommandWithExecutorThatThrowsException = MockRepository.GenerateMock<ICommandExecutor<CommandWithExecutorThatThrowsException>>();

            Interceptor1 = MockRepository.GenerateMock<ICommandServiceInterceptor>();
            Interceptor2 = MockRepository.GenerateMock<ICommandServiceInterceptor>();

            ExecutorForCommandWithExecutorThatThrowsException.Stub(e=>e.Execute(null)).IgnoreArguments().Throw(new Exception());

            service.RegisterExecutor(ExecutorForCommandWithExecutor);
            service.RegisterExecutor(ExecutorForCommandWithExecutorThatThrowsException);

            service.AddInterceptor(Interceptor1);
            service.AddInterceptor(Interceptor2);

            TheService = service;
        }
Beispiel #6
0
        private static ICommandService InitializeCommandService()
        {
            var commandAssembly = typeof(CreateNewNote).Assembly;
            var service         = new CommandService();

            service.RegisterExecutorsInAssembly(commandAssembly);
            service.AddInterceptor(new ThrowOnExceptionInterceptor());

            return(service);
        }
        public void Setup()
        {
            var service = new CommandService();

            ExecutorForCommandWithExecutor = MockRepository.GenerateMock <ICommandExecutor <CommandWithExecutor> >();
            ExecutorForCommandWithExecutorThatThrowsException = MockRepository.GenerateMock <ICommandExecutor <CommandWithExecutorThatThrowsException> >();

            Interceptor1 = MockRepository.GenerateMock <ICommandServiceInterceptor>();
            Interceptor2 = MockRepository.GenerateMock <ICommandServiceInterceptor>();

            ExecutorForCommandWithExecutorThatThrowsException.Stub(e => e.Execute(null)).IgnoreArguments().Throw(new Exception());

            service.RegisterExecutor(ExecutorForCommandWithExecutor);
            service.RegisterExecutor(ExecutorForCommandWithExecutorThatThrowsException);

            service.AddInterceptor(Interceptor1);
            service.AddInterceptor(Interceptor2);

            TheService = service;
        }
Beispiel #8
0
        public override void Load()
        {
            Kernel.Bind<IUniqueIdentifierGenerator>()
                .To<GuidCombGenerator>();

            var eventStoreConnectionString = ConfigurationManager.ConnectionStrings["EventStore"].ConnectionString;
            Kernel.Bind<IEventStore>()
                .ToMethod(ctx => new MsSqlServerEventStore(eventStoreConnectionString))
                .InSingletonScope();

            Kernel.Bind<IEventBus>()
                .ToMethod(ctx => new InProcessEventBus().RegisterDenormalizers(Kernel))
                .InSingletonScope();

            Kernel.Bind<IAggregateRootCreationStrategy>()
                .To<NinjectAggregateRootCreationStrategy>()
                .InSingletonScope();

            Kernel.Bind<IDomainRepository>()
                .To<DomainRepository>()
                .InSingletonScope();

            Kernel.Bind<ICommandServiceInterceptor>()
                .To<ValidationCommandInterceptor>()
                .InSingletonScope();

            Kernel.Bind<ICommandServiceInterceptor>()
                .To<SetValidationCommandInterceptor>()
                .InSingletonScope();

            Kernel.Bind<ICommandService>()
                .ToMethod(ctx =>
                              {
                                  var cs = new CommandService();
                                  cs.Configure();
                                  var interceptors = ctx.Kernel.GetAll<ICommandServiceInterceptor>();
                                  foreach (var interceptor in interceptors)
                                      cs.AddInterceptor(interceptor);
                                  return cs;
                              })
                .InSingletonScope();

            Kernel.Bind<IMapMaker>()
                .ToMethod(ctx => ctx.Kernel.Get<NHibernateMapMaker>());

            Kernel.Bind<Map>()
                .ToMethod(ctx => ctx.Kernel.Get<IMapMaker>().MakeMap())
                .InSingletonScope();

            Kernel.Bind<IDialect>()
                .ToMethod(ctx => new MsSqlDialect(ctx.Kernel.Get<Map>()))
                .InSingletonScope();
        }
Beispiel #9
0
        public override void Load()
        {
            Kernel.Bind<IKernel>().ToConstant(Kernel);

            var commandService = new CommandService();
            commandService.Configure();
            commandService.AddInterceptor(new ValidationCommandInterceptor());
            Kernel.Bind<ICommandService>().ToConstant(commandService);

            Kernel.Bind<IAggregateRootCreationStrategy>().To<NinjectAggregateRootCreationStrategy>();

            Kernel.Bind<IClock>().To<DateTimeBasedClock>();
        }