private static void ValidateDevOpsCredentials(TestManagementHttpClient testManagementHttpClient) { _commandLineAccess.WriteToConsole(_messages.Stages.DevOpsCredentials.Status, _messages.Types.Stage); TestPlan testPlan; try { testPlan = testManagementHttpClient.GetPlansAsync(_inputOptions.ProjectName).Result.Single(x => x.Id.Equals(_inputOptions.TestPlanId)); } catch (Exception e) { var innerException = e.InnerException ?? e; var innerExceptionType = innerException.GetType(); var message = innerException.Message; if (innerExceptionType == typeof(VssUnauthorizedException)) { message = string.Format(_messages.Stages.DevOpsCredentials.FailureUserNotAuthorized, _inputOptions.CollectionUri); } else if (innerExceptionType == typeof(ProjectDoesNotExistWithNameException)) { message = string.Format(_messages.Stages.DevOpsCredentials.FailureNonExistingProject, _inputOptions.ProjectName); } else if (innerExceptionType == typeof(InvalidOperationException) && e.Message.Equals(SequenceContainsNoMatchingElementName)) { message = string.Format(_messages.Stages.DevOpsCredentials.FailureNonExistingTestPlan, _inputOptions.TestPlanId); } _commandLineAccess.WriteToConsole(message, _messages.Types.Error); throw innerException; } try { _ = testManagementHttpClient.GetTestSuitesForPlanAsync(_inputOptions.ProjectName, testPlan.Id).Result.Single(x => x.Id.Equals(_inputOptions.TestSuiteId)); } catch (Exception e) { var innerException = e.InnerException ?? e; var innerExceptionType = innerException.GetType(); var message = innerException.Message; if (innerExceptionType == typeof(VssUnauthorizedException)) { message = string.Format(_messages.Stages.DevOpsCredentials.FailureUserNotAuthorized, _inputOptions.CollectionUri); } else if (innerExceptionType == typeof(InvalidOperationException) && e.Message.Equals(SequenceContainsNoMatchingElementName)) { message = string.Format(_messages.Stages.DevOpsCredentials.FailureNonExistingTestSuite, _inputOptions.TestSuiteId); } _commandLineAccess.WriteToConsole(message, _messages.Types.Error); throw innerException; } _commandLineAccess.WriteToConsole(_messages.Stages.DevOpsCredentials.Success, _messages.Types.Success); }
public async Task <List <TestPlan> > GetTestPlan() { TestManagementHttpClient witClient = connection.GetClient <TestManagementHttpClient>(); List <TestPlan> TestPlanList = await witClient.GetPlansAsync(Project, null, null, null, null, null, null, default(System.Threading.CancellationToken)); return(TestPlanList); }