public void ShouldUseRegisteredQueryHandlerToExecuteQuery()
            {
                const string expectedResult = "expectedResult";
                var          mockHandler    = new TestQueryHandler1 <TestQuery1, string>(expectedResult);
                ICollection <ICommandHandler> commandHandlers =
                    Enumerable.Repeat <ICommandHandler>(new TestCommandHandler1 <TestCommand1>(), 1).ToList();
                ICollection <IQueryHandler> queryHandlers = new List <IQueryHandler>
                {
                    mockHandler
                };
                var query = new TestQuery1();

                var    dispatcher  = new CommandAndQueryDispatcher(commandHandlers, queryHandlers);
                string queryResult = dispatcher.ExecuteQuery(query);

                mockHandler.QueryExecuted.Should().Be(query);
                queryResult.Should().Be(expectedResult);
            }
            public void ShouldThrowInvalidOperationExceptionWhenQueryHandlerIsNotRegistered()
            {
                const string expectedResult  = "expectedResult";
                const string expectedResult2 = "expectedResult2";
                var          mockHandler     = new TestQueryHandler1 <TestQuery1, string>(expectedResult);
                ICollection <ICommandHandler> commandHandlers =
                    Enumerable.Repeat <ICommandHandler>(new TestCommandHandler1 <TestCommand1>(), 1).ToList();
                ICollection <IQueryHandler> queryHandlers = new List <IQueryHandler>
                {
                    mockHandler,
                };
                var query = new TestQuery2();

                var    dispatcher = new CommandAndQueryDispatcher(commandHandlers, queryHandlers);
                string queryResult;
                Action action = () => queryResult = dispatcher.ExecuteQuery(query);

                action.ShouldThrow <InvalidOperationException>();
            }