/// <summary> /// Imports the test plans /// </summary> /// <param name="streamWriter"></param> /// <param name="spiraClient"></param> /// <param name="testRailApi"></param> private void ImportTestPlans(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, APIClient testRailApi) { //Get the test cases from the TestRail API JArray testPlans = (JArray)testRailApi.SendGet("get_plans/" + this.testRailProjectId); if (testPlans != null) { foreach (JObject testPlan in testPlans) { //Extract the test rail data int testRailId = testPlan["id"].Value <int>(); bool isCompleted = testPlan["is_completed"].Value <bool>(); //Create the new SpiraTest test set RemoteTestSet remoteTestSet = new RemoteTestSet(); remoteTestSet.Name = testPlan["name"].Value <string>(); remoteTestSet.Description = testPlan["description"].Value <string>(); remoteTestSet.TestSetStatusId = (isCompleted) ? /* Completed */ 3 : /* Not Started */ 1; remoteTestSet.TestRunTypeId = 1; /* Manual */ int?createdById = testPlan["created_by"].Value <int?>(); if (createdById.HasValue && this.usersMapping.ContainsKey(createdById.Value)) { remoteTestSet.CreatorId = this.usersMapping[createdById.Value]; } int newTestSetId = spiraClient.TestSet_Create(remoteTestSet).TestSetId.Value; streamWriter.WriteLine("Added test plan: " + testRailId); //Add to the mapping dictionary if (!this.testSetMapping.ContainsKey(testRailId)) { this.testSetMapping.Add(testRailId, newTestSetId); } //Test Rail doesn't map test cases to test plans, so we don't map them } } }