Example #1
0
        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);
        }
Example #2
0
        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);
            });
        }
Example #3
0
        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);
            });
        }