public void cancel_should_not_cancel_others()
        {
            var bus     = new CommandBus("local");
            var handler = new CancelableTestCommandHandler();

            bus.Subscribe((IHandleCommand <TestCommands.TestCommand>)handler);
            bus.Subscribe((IHandleCommand <TestCommands.TestCommand2>)handler);
            var handler2 = new TestCommandHandler();

            bus.Subscribe((IHandleCommand <TestCommands.TestCommand3>)handler2);
            var cmd1 = new TestCommands.TestCommand(Guid.NewGuid(), null);
            var cmd2 = new TestCommands.TestCommand2(Guid.NewGuid(), null);
            var cmd3 = new TestCommands.TestCommand3(Guid.NewGuid(), null);

            Task.Delay(100).ContinueWith(t => bus.RequestCancel(cmd1));
            Task.Run(() => bus.Fire(cmd2));
            Task.Run(() => bus.Fire(cmd3));
            Assert.Throws <CommandCanceledException>(
                () =>
            {
                try
                {
                    bus.Fire(cmd1);
                }
                catch (Exception ex)
                {
                    throw ex.InnerException;
                }
            });
        }
        public void noncancelable_commands_will_ignore_cancel()
        {
            var bus     = new CommandBus("local");
            var handler = new TestCommandHandler();

            bus.Subscribe((IHandleCommand <TestCommands.TestCommand3>)handler);
            var cmd = new TestCommands.TestCommand3(Guid.NewGuid(), null);

            Task.Delay(100).ContinueWith(t => bus.RequestCancel(cmd));

            bus.Fire(cmd);
        }
        public void cancelable_commands_can_be_canceled()
        {
            var bus     = new CommandBus("local");
            var handler = new CancelableTestCommandHandler();

            bus.Subscribe((IHandleCommand <TestCommands.TestCommand>)handler);
            var cmd = new TestCommands.TestCommand(Guid.NewGuid(), null);

            Task.Delay(100).ContinueWith(t => bus.RequestCancel(cmd));

            Assert.Throws <CommandCanceledException>(
                () =>
            {
                try
                {
                    bus.Fire(cmd);
                }
                catch (Exception ex)
                {
                    throw ex.InnerException;
                }
            });
        }