public void NoDispatcher()
        {
            CommandDispatcher.Assign(null);
            var command = Substitute.For <ICommand>();

            Assert.Throws <InvalidOperationException>(() => CommandDispatcher.Dispatch(command));
        }
 /// <summary>
 /// Dispatch commands using our favorite container
 /// </summary>
 /// <param name="container">Container instance.</param>
 public static void DispatchCommands(this IParentContainer container)
 {
     if (container == null)
     {
         throw new ArgumentNullException("container");
     }
     CommandDispatcher.Assign(new Commands.IocDispatcher(new ContainerAdapter(container)));
 }
        public void RegularDispatch()
        {
            var innerDispatcher = Substitute.For <ICommandDispatcher>();

            CommandDispatcher.Assign(innerDispatcher);
            var command = new FakeCommand();

            CommandDispatcher.Dispatch(command);

            innerDispatcher.Received().Dispatch(Arg.Is <FakeCommand>(x => ReferenceEquals(x, command)));
        }
Пример #4
0
        public void Complete()
        {
            var builder    = new PipelineDispatcherBuilder(Substitute.For <IUpstreamHandler>());
            var dispatcher = builder
                             .AsyncDispatching(10)
                             .RetryCommands(4)
                             .Dispatcher(Substitute.For <IDownstreamHandler>())
                             .Build();

            CommandDispatcher.Assign(dispatcher);

            CommandDispatcher.Dispatch(new FakeCommand());
        }
Пример #5
0
        private static void Main(string[] args)
        {
            var container = ConfigureGriffinContainer();

            // will recieve any pipeline errors (i.e. failing to deliver the commands)
            var errorHandler = new ErrorHandler();

            // will also assign the pipeline
            var dispatcher = new PipelineDispatcherBuilder(errorHandler)
                             .AsyncDispatching(10)           // allow 10 commands to be dispatched simultaneosly
                             .UseGriffinContainer(container) // Use Griffin.Container (the "griffin.decoupled.container" nuget package)
                             .Build();                       // and lets go.

            // assign it
            CommandDispatcher.Assign(dispatcher);

            Console.WriteLine("We are on thread #" + Thread.CurrentThread.ManagedThreadId);
            CommandDispatcher.Dispatch(new SayHello());

            Console.ReadLine();
        }
Пример #6
0
        private static void Main(string[] args)
        {
            var container = ConfigureGriffinContainer();

            // will recieve any pipeline errors (i.e. failure to deliver the messages)
            var errorHandler = new ErrorHandler();

            // will also assign the pipeline
            var dispatcher = new PipelineDispatcherBuilder(errorHandler)
                             .AsyncDispatching(10)           // allow 10 commands to be dispatched simultaneosly
                             .RetryCommands(3)               // attempt to execute commands three times.
                             .UseGriffinContainer(container) // Use Griffin.Container (the "Griffin.Decoupled.Container" nuget package)
                             .UseRavenDbEmbedded()           // use RavenDb to store pending commands (the "Griffin.Decoupled.RavenDb.Embedded" nuget package)
                             .Build();                       // and lets go.

            // assign it
            CommandDispatcher.Assign(dispatcher);

            Console.WriteLine("We are on thread #" + Thread.CurrentThread.ManagedThreadId);
            CommandDispatcher.Dispatch(new SayHello());

            Console.ReadLine();
        }