public void WhenExecuteCommandWithoutRegisteredKeyAndValue_CommandManager_ShouldUpdate() { string key = "my.param"; string value = "my new value"; var storedDataService = new StoredDataServiceMock() { ReturnBoolExistsParameter = true }; var commandDefinition = new UpdateParameterCommand(storedDataService); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandKeyParameter.GetInvokeName(), key, commandDefinition.CommandValueParameter.GetInvokeName(), value); instance.ExecuteInputRequest(inputRequest); var expectedKey = key; var actualKey = storedDataService.UpdatedParameterKey; Assert.Equal(expectedKey, actualKey); var expectedValue = value; var actualValue = storedDataService.UpdatedParameterValue; Assert.Equal(expectedValue, actualValue); }
public void WhenExecuteCommandWithoutCommandKey_CommandManager_ShouldThrowException() { string value = "my value"; var storedDataService = new StoredDataServiceMock(); var commandDefinition = new UpdateParameterCommand(storedDataService); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandValueParameter.GetInvokeName(), value); Assert.Throws <InvalidParamsException>(() => { instance.ExecuteInputRequest(inputRequest); }); }