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); }
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); }); }
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); }); }