public void WhenExecuteCommandWithValidPipeline_CommandManager_ShouldThrowException() { string pipelineName = "myPipeline"; var storedDataService = new StoredDataServiceMock() { ExistsPipelineReturn = true }; var commandDefinition = new DeletePipelineCommand(storedDataService); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandNameParameter.GetInvokeName(), pipelineName); instance.ExecuteInputRequest(inputRequest); var expected = pipelineName; var actual = storedDataService.DeletedPipeline; Assert.Equal(expected, actual); }
private void btnDeletePipeline_Click(object sender, RoutedEventArgs e) { DeliveryPipeline pipeline = ((Button)sender).DataContext as DeliveryPipeline; if (MessageBox.Show(string.Format("Are you sure you want to remove pipeline \"{0}\"\r\nfrom \"{1}\"?", pipeline.ScriptName, pipeline.ProjectName), "Confirm remove pipeline", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { DeletePipelineCommand command = new DeletePipelineCommand(); command.Name = pipeline.ScriptName; command.CollectionURL = pipeline.Source.Uri; command.ProjectName = pipeline.ProjectName; try { command.BuildCommand(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Correct invalid entries", MessageBoxButton.OK, MessageBoxImage.Error); return; } NavigationService _navService = NavigationService; _navService.Navigate(new RunPowerShell(this, "Removing pipeline", command, null, () => { ClientConfiguration.Current.RefreshSources(); _navService.Navigate(new Home(_clientControl)); return(true); }, () => { _navService.Navigate(new Home(_clientControl)); return(true); } )); } }
public void WhenExecuteCommandWithoutNameParameter_CommandManager_ShouldThrowException() { var storedDataService = new StoredDataServiceMock(); var commandDefinition = new DeletePipelineCommand(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 WhenExecuteCommandWithNonExistingPipeline_CommandManager_ShouldThrowException() { string pipelineName = "myPipeline"; var storedDataService = new StoredDataServiceMock() { ExistsPipelineReturn = false }; var commandDefinition = new DeletePipelineCommand(storedDataService); var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock); instance.RegisterCommand(commandDefinition); var inputRequest = new InputRequest( commandDefinition.GetInvocationCommandName(), commandDefinition.CommandNameParameter.GetInvokeName(), pipelineName); Assert.Throws <PipelineNotFoundException>(() => { instance.ExecuteInputRequest(inputRequest); }); }