public void WhenExecuteCommand_CommandManager_ShouldAddAlias() { string aliasName = "myalias"; string commandName = "mycommand"; string commandNamespace = "name.space"; string commandDescription = "description"; var storedDataService = new StoredDataServiceMock(true); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(new CommandMock(commandNamespace, commandName, commandDescription)); var commandDefinition = new DeleteAliasCommand(storedDataService); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandAliasParameter.GetInvokeName(), aliasName); instance.ExecuteInputRequest(inputRequest); var storedAlias = storedDataService.DeletedAlias; var actual = storedAlias == aliasName; Assert.True(actual); }
public void WhenExecuteCommandWithoutAliasParameter_CommandManager_ShouldThrowException() { var storedDataService = new StoredDataServiceMock(false); var commandDefinition = new DeleteAliasCommand(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 WhenExecuteCommandWithNonExistingAliasParameter_CommandManager_ShouldThrowException() { string aliasName = "myalias"; var storedDataService = new StoredDataServiceMock(false); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); var commandDefinition = new DeleteAliasCommand(storedDataService); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandAliasParameter.GetInvokeName(), aliasName); Assert.Throws <AliasNotFoundException>(() => { instance.ExecuteInputRequest(inputRequest); }); }