コード例 #1
0
        public void TestFixtureSetUp()
        {
            _container = new WindsorContainer();
            _container.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
            String connectionString = ConfigurationManager.ConnectionStrings["log"].ConnectionString;
            var    rebusUrl         = new MongoUrl(connectionString);
            var    rebusClient      = rebusUrl.CreateClient(false);
            var    rebusDb          = rebusClient.GetDatabase(rebusUrl.DatabaseName);

            _messages = rebusDb.GetCollection <TrackedMessageModel>("messages");
            MongoDbMessagesTracker tracker = new MongoDbMessagesTracker(rebusDb);

            JarvisRebusConfiguration configuration = new JarvisRebusConfiguration(connectionString, "test")
            {
                ErrorQueue   = "jarvistest-errors",
                InputQueue   = "jarvistest-input",
                MaxRetry     = 3,
                NumOfWorkers = 1,
                EndpointsMap = new System.Collections.Generic.Dictionary <string, string>()
                {
                    { "Jarvis.Framework.Tests", "jarvistest-input" }
                }
            };

            configuration.AssembliesWithMessages = new List <System.Reflection.Assembly>()
            {
                typeof(SampleMessage).Assembly,
            };

            JarvisTestBusBootstrapper bb = new JarvisTestBusBootstrapper(
                _container,
                configuration,
                tracker);

            TestHelper.RegisterSerializerForFlatId <SampleAggregateId>();

            bb.Start();
            var rebusConfigurer = _container.Resolve <RebusConfigurer>();

            rebusConfigurer.Start();
            _bus = _container.Resolve <IBus>();

            _handler = new SampleCommandHandler();
            _commandExecutionExceptionHelper = new JarvisDefaultCommandExecutionExceptionHelper(NullLogger.Instance, 20, 10);
            var handlerAdapter = new MessageHandlerToCommandHandlerAdapter <SampleTestCommand>(_handler, _commandExecutionExceptionHelper, tracker, _bus);

            _container.Register(
                Component
                .For <IHandleMessages <SampleTestCommand> >()
                .Instance(handlerAdapter)
                );

            var handlerAggregateAdapter = new MessageHandlerToCommandHandlerAdapter <SampleAggregateTestCommand>(_handler, _commandExecutionExceptionHelper, tracker, _bus);

            _container.Register(
                Component
                .For <IHandleMessages <SampleAggregateTestCommand> >()
                .Instance(handlerAggregateAdapter)
                );
        }
コード例 #2
0
 public void TestFixtureSetUp()
 {
     String connectionString = ConfigurationManager.ConnectionStrings["log"].ConnectionString;
     var logUrl = new MongoUrl(connectionString);
     var logClient = new MongoClient(logUrl);
     var logDb = logClient.GetDatabase(logUrl.DatabaseName);
     sut = new MongoDbMessagesTracker(logDb);
     _messages = logDb.GetCollection<TrackedMessageModel>("messages");
 }
コード例 #3
0
        public void TestFixtureSetUp()
        {
            _container = new WindsorContainer();
            String connectionString = ConfigurationManager.ConnectionStrings["log"].ConnectionString;
            var    logUrl           = new MongoUrl(connectionString);
            var    logClient        = logUrl.CreateClient(false);
            var    logDb            = logClient.GetDatabase(logUrl.DatabaseName);

            logDb.Drop();

            _messages = logDb.GetCollection <TrackedMessageModel>("messages");

            JarvisRebusConfiguration configuration = new JarvisRebusConfiguration(connectionString, "test")
            {
                ErrorQueue   = "jarvistest-errors",
                InputQueue   = "jarvistest-input",
                MaxRetry     = RebusMaxRetry,
                NumOfWorkers = 1,
                EndpointsMap = new System.Collections.Generic.Dictionary <string, string>()
                {
                    ["Jarvis.Framework.Tests"] = "jarvistest-input"
                }
            };

            configuration.AssembliesWithMessages = new List <System.Reflection.Assembly>()
            {
                typeof(SampleMessage).Assembly,
            };

            MongoDbMessagesTracker tracker = new MongoDbMessagesTracker(logDb);
            BusBootstrapper        bb      = CreateBusBootstrapper(tracker, configuration);

            bb.Start();
            var rebusConfigurer = _container.Resolve <RebusConfigurer>();

            rebusConfigurer.Start();

            _bus = _container.Resolve <IBus>();
            var handler = new AnotherSampleCommandHandler();

            var commandExecutionExceptionHelper = new JarvisDefaultCommandExecutionExceptionHelper(NullLogger.Instance, 20, 10);
            var handlerAdapter = new MessageHandlerToCommandHandlerAdapter <AnotherSampleTestCommand>(
                handler, commandExecutionExceptionHelper, tracker, _bus);

            _container.Register(
                Component
                .For <IHandleMessages <AnotherSampleTestCommand> >()
                .Instance(handlerAdapter)
                );
        }
コード例 #4
0
        public void TestFixtureSetUp()
        {
            String connectionString = ConfigurationManager.ConnectionStrings["log"].ConnectionString;
            var    url    = new MongoUrl(connectionString);
            var    client = url.CreateClient(false);
            var    db     = client.GetDatabase(url.DatabaseName);

            db.Drop();
            _messages = db.GetCollection <TrackedMessageModel>("messages");
            _tracker  = new MongoDbMessagesTracker(db);
            TestHelper.RegisterSerializerForFlatId <SampleAggregateId>();

            GenerateData();
        }
コード例 #5
0
 private BusBootstrapper CreateBusBootstrapper(MongoDbMessagesTracker tracker, JarvisRebusConfiguration configuration)
 {
     if (_transportType == "msmq")
     {
         return(new MsmqTransportJarvisTestBusBootstrapper(
                    _container,
                    configuration,
                    tracker));
     }
     else
     {
         return(new MongoDbTransportJarvisTestBusBootstrapper(
                    _container,
                    configuration,
                    tracker));
     }
 }
コード例 #6
0
        public void TestFixtureSetUp()
        {
            _container = new WindsorContainer();
            
            String connectionString = ConfigurationManager.ConnectionStrings["log"].ConnectionString;
            var rebusUrl = new MongoUrl(connectionString);
            var rebusClient = new MongoClient(rebusUrl);
            var rebusDb = rebusClient.GetDatabase(rebusUrl.DatabaseName);
            _messages = rebusDb.GetCollection<TrackedMessageModel>("messages");
            MongoDbMessagesTracker tracker = new MongoDbMessagesTracker(rebusDb);
            BusBootstrapper bb = new BusBootstrapper(
                _container,
                connectionString,
                "test",
                tracker);
            JarvisRebusConfiguration configuration = new JarvisRebusConfiguration()
            {
                ErrorQueue = "jarvistest-errors",
                InputQueue = "jarvistest-input",
                MaxRetry = 3,
                NumOfWorkers = 1,
                EndpointsMap = new System.Collections.Generic.Dictionary<string, string>()
                {
                    { "Jarvis.Framework.Tests" , "jarvistest-input"}
                }
            };
            bb.Configuration = configuration;
            bb.Start();
            var startableBus = _container.Resolve<IStartableBus>();
            startableBus.Start();
            _bus = _container.Resolve<IBus>();
            
            _handler = new SampleCommandHandler();
            _handlerAdapter = new MessageHandlerToCommandHandlerAdapter<SampleTestCommand>(
                _handler, tracker, _bus);

            _container.Register(
                Component
                    .For<IHandleMessages<SampleTestCommand>>()
                    .Instance(_handlerAdapter)
            );
        }