コード例 #1
0
        public void WhenExecuteCommandWithParameter_CommandManager_ShouldDeleteParameter()
        {
            var key = "my.parameter";

            var storedDataService = new StoredDataServiceMock()
            {
                ReturnBoolExistsParameter = true
            };
            var commandDefinition = new DeleteParameterCommand(storedDataService);

            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);

            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName(),
                commandDefinition.CommandKeyParameter.GetInvokeName(),
                key);

            instance.ExecuteInputRequest(inputRequest);

            var expected = key;
            var actual   = storedDataService.DeletedParameter;

            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void WhenExecuteCommandWithoutCommandKey_CommandManager_ShouldThrowException()
        {
            var storedDataService = new StoredDataServiceMock();
            var commandDefinition = new DeleteParameterCommand(storedDataService);

            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);

            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName());

            Assert.Throws <InvalidParamsException>(() =>
            {
                instance.ExecuteInputRequest(inputRequest);
            });
        }
コード例 #3
0
        public void WhenExecuteCommandWithNotRegisteredParameter_CommandManager_ShouldThrowException()
        {
            var key = "my.parameter";

            var storedDataService = new StoredDataServiceMock()
            {
                ReturnBoolExistsParameter = false
            };
            var commandDefinition = new DeleteParameterCommand(storedDataService);

            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);

            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName(),
                commandDefinition.CommandKeyParameter.GetInvokeName(),
                key);

            Assert.Throws <ParameterNotFoundException>(() =>
            {
                instance.ExecuteInputRequest(inputRequest);
            });
        }