diff --git a/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsTestPlansAndSuitesMigrationProcessor.cs b/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsTestPlansAndSuitesMigrationProcessor.cs index a14112d6b..79662a0ef 100644 --- a/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsTestPlansAndSuitesMigrationProcessor.cs +++ b/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsTestPlansAndSuitesMigrationProcessor.cs @@ -607,8 +607,16 @@ private ITestSuiteBase FindSuiteEntry(IStaticTestSuite staticSuite, string title private ITestPlan FindTestPlan(string planName, int sourcePlanId) { Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan"); - ITestPlan testPlan = (from p in _targetTestStore.Project.TestPlans.Query("Select * From TestPlan") where p.Name == planName select p).SingleOrDefault(); - + ITestPlan testPlan; + List testPlans = (from p in _targetTestStore.Project.TestPlans.Query("Select * From TestPlan") where p.Name == planName select p).ToList(); + if (testPlans.Count > 1) + { + string result = string.Join(",", testPlans.Select(obj => obj.Id)); + Log.LogWarning("We found multiple test Plans with the name '{TestPlanName}'. They have ID(s) of '{result}'! We only have name at this point as a unique identifier and duplicates will break the code. Ensure that all Test Plans have unique names.", planName, result); + throw new Exception(string.Format("Test plans {0} all have the same name!", result)); + } + testPlan = testPlans[0]; + if (testPlan != null) { Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: FOUND Test Plan with {name}", planName); @@ -1173,4 +1181,4 @@ private void ValidateAndFixTestSuiteQuery(ITestSuiteBase source, IDynamicTestSui } } } -} \ No newline at end of file +}