public void Execute_ShouldExecuteARealCommandHandler_WithNoResult()
        {
            var command = new CommandNoResult();
            this.factoryMock.Setup(
                x =>
                x.Get<IDbContextDatabaseCommandHandler>(
                    typeof(IDbContextDatabaseCommandHandler<CommandNoResult>)))
                .Returns(new CommandNoResultHandler());

            using (var context = this.CreateContext())
            {
                context.Start();

                Assert.That(() => context.Execute(command), Throws.Nothing);
            }
        }
        public void Execute_ShouldThrowException_WhenNoCommandHandlerFound()
        {
            var commandNoResult = new CommandNoResult();
            var commandWithResult = new CommandWithResult();

            using (var context = this.CreateContext())
            {
                context.Start();
                Assert.That(
                    () => context.Execute(commandNoResult),
                    Throws.Exception.TypeOf<HexagonException>().With.Message.ContainsSubstring("appropriate handler"));
                Assert.That(
                    () => context.Execute(commandWithResult),
                    Throws.Exception.TypeOf<HexagonException>().With.Message.ContainsSubstring("appropriate handler"));
            }
        }
        public void Execute_ShouldSelectCommandHandler_AndInvokeHandle_WithNoResult()
        {
            var command = new CommandNoResult();
            var commandHandlerMock = new Mock<IDbContextDatabaseCommandHandler<CommandNoResult>>();
            this.factoryMock.Setup(x => x.Get<IDbContextDatabaseCommandHandler>(typeof(IDbContextDatabaseCommandHandler<CommandNoResult>)))
                            .Returns(commandHandlerMock.Object)
                            .Verifiable();

            using (var context = this.CreateContext())
            {
                context.Start();
                context.Execute(command);
                commandHandlerMock.Verify(x => x.Handle(command, It.IsNotNull<DbContext>()));
                this.factoryMock.Verify();
            }
        }