public void WhenExecuteCommandWithValidTemplate_CommandManager_ShouldThrowException() { string templateName = "myTemplate"; var storedDataService = new StoredDataServiceMock() { ExistsTemplateReturn = true }; var commandDefinition = new DeleteTemplateCommand(storedDataService); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandNameParameter.GetInvokeName(), templateName); instance.ExecuteInputRequest(inputRequest); var expected = templateName; var actual = storedDataService.DeletedTemplate; Assert.Equal(expected, actual); }
public void WhenExecuteCommandWithoutNameParameter_CommandManager_ShouldThrowException() { var storedDataService = new StoredDataServiceMock(); var commandDefinition = new DeleteTemplateCommand(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 WhenExecuteCommandWithTemplateNonExistingTemplate_CommandManager_ShouldThrowException() { string templateName = "myTemplate"; var storedDataService = new StoredDataServiceMock() { ExistsTemplateReturn = false }; var commandDefinition = new DeleteTemplateCommand(storedDataService); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandNameParameter.GetInvokeName(), templateName); Assert.Throws <TemplateNotFoundException>(() => { instance.ExecuteInputRequest(inputRequest); }); }