示例#1
0
        public void throws_exception_if_argument_is_invalid_type()
        {
            var dummyCommand    = new Mock <ICommand <EmptyArgument> >().Object;
            var invalidArgument = "string is not a valid command type";

            var sut = new DefaultCommandExecutor();

            Assert.Throws <NotSupportedException>(() => sut.Execute(dummyCommand, invalidArgument));
        }
示例#2
0
        public void throws_exception_if_command_is_invalid_type()
        {
            var invalidCommand = "string is not a valid command type";
            var dummyArgument  = new EmptyArgument();

            var sut = new DefaultCommandExecutor();

            Assert.Throws <NotSupportedException>(() => sut.Execute(invalidCommand, dummyArgument));
        }
示例#3
0
        public void invokes_execute_method()
        {
            var mock          = new Mock <ICommand <EmptyArgument> >();
            var dummyArgument = new EmptyArgument();
            var sut           = new DefaultCommandExecutor();

            sut.Execute(mock.Object, dummyArgument);

            mock.Verify(x => x.Execute(dummyArgument));
        }
示例#4
0
        public void invokes_expected_method_when_overloads_exists()
        {
            var spy = new SpyOverloadExecuteMethodCommand();

            var sut = new DefaultCommandExecutor();

            sut.Execute(spy, new EmptyArgument());

            Assert.True(spy.wasExpectedInvoked);
        }
        private ICommandExecutor CreateCommandExecutor(int maxQueryConnectionsLimit)
        {
            var commandExecutor = new DefaultCommandExecutor(maxQueryConnectionsLimit);

            commandExecutor.OnGetConnections += (c, s, i) =>
            {
                if (_shardingConnection != null)
                {
                    return(_shardingConnection.GetConnections(c, s, i));
                }

                throw new ShardingException(
                          $"{nameof(ShardingCommand)} {nameof(_shardingConnection)} is null");
            };
            return(commandExecutor);
        }