Skip to content

Commit e06fec6

Browse files
committed
PR 51: Merge bug/4892-ObjectNotSetToInstance to master
- Updated and fixed Veriable createion #4892 +semver:minor - Fixed null in AreaIterationPath of configursation +semver:patch Related work items: #4892
1 parent b474f5a commit e06fec6

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

TfsWitMigrator.Core/Execution/MigrationContext/TestPlansAndSuitsMigrationContext.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace VSTS.DataBulkEditor.Engine
1313
{
1414
public class TestPlansAndSuitsMigrationContext : MigrationContextBase
1515
{
16+
MigrationEngine engine;
1617

1718
WorkItemStoreContext sourceWitStore;
1819
TestManagementContext sourceTestStore;
@@ -33,6 +34,7 @@ public override string Name
3334

3435
public TestPlansAndSuitsMigrationContext(MigrationEngine me, TestPlansAndSuitsMigrationConfig config) : base(me, config)
3536
{
37+
this.engine = me;
3638
sourceWitStore = new WorkItemStoreContext(me.Source, WorkItemStoreFlags.None);
3739
sourceTestStore = new TestManagementContext(me.Source);
3840
targetWitStore = new WorkItemStoreContext(me.Target, WorkItemStoreFlags.BypassRules);
@@ -321,8 +323,14 @@ private ITestPlan CreateNewTestPlanFromSource(ITestPlan sourcePlan, string newP
321323
targetPlan.Name = newPlanName;
322324
targetPlan.StartDate = sourcePlan.StartDate;
323325
targetPlan.EndDate = sourcePlan.EndDate;
324-
targetPlan.AreaPath = this.config.AreaIterationPath;
325-
targetPlan.Iteration = this.config.AreaIterationPath;
326+
if (this.config.AreaIterationPath == null){
327+
targetPlan.AreaPath = sourcePlan.AreaPath.Replace(engine.Source.Name, string.Format(@"{0}\{1}", engine.Target.Name, engine.Source.Name));
328+
targetPlan.Iteration = sourcePlan.Iteration.Replace(engine.Source.Name, string.Format(@"{0}\{1}", engine.Target.Name, engine.Source.Name));
329+
} else
330+
{
331+
targetPlan.AreaPath = this.config.AreaIterationPath;
332+
targetPlan.Iteration = this.config.AreaIterationPath;
333+
}
326334
targetPlan.ManualTestSettingsId = 0;
327335
return targetPlan;
328336
}

TfsWitMigrator.Core/Execution/MigrationContext/TestVeriablesMigrationContext.cs

+23-20
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,34 @@ internal override void InternalExecute()
4444
{
4545
Trace.WriteLine(string.Format("Copy: {0}", sourceVar.Name));
4646
ITestVariable targetVar= GetVar(targetTmc.Project.TestVariables, sourceVar.Name);
47-
if (targetVar != null)
47+
if (targetVar == null)
4848
{
49-
Trace.WriteLine(string.Format(" Exists: {0}", sourceVar.Name));
50-
// match values
51-
foreach (var sourceVal in sourceVar.AllowedValues)
52-
{
53-
Trace.WriteLine(string.Format(" Seeking: {0}", sourceVal.Value));
54-
ITestVariableValue targetVal = GetVal(targetVar, sourceVal.Value);
55-
if (targetVal != null)
56-
{
57-
Trace.WriteLine(string.Format(" Exists: {0}", targetVal.Value));
58-
59-
} else
60-
{
61-
Trace.WriteLine(string.Format(" Need to create: {0}", targetVal.Value));
62-
throw new NotImplementedException();
63-
}
64-
}
49+
Trace.WriteLine(string.Format(" Need to create: {0}", sourceVar.Name));
50+
targetVar = targetTmc.Project.TestVariables.Create();
51+
targetVar.Name = sourceVar.Name;
52+
targetVar.Save();
6553
}
6654
else
6755
{
68-
Trace.WriteLine(string.Format(" Need to create: {0}", sourceVar.Name));
69-
throw new NotImplementedException();
56+
Trace.WriteLine(string.Format(" Exists: {0}", sourceVar.Name));
57+
}
58+
// match values
59+
foreach (var sourceVal in sourceVar.AllowedValues)
60+
{
61+
Trace.WriteLine(string.Format(" Seeking: {0}", sourceVal.Value));
62+
ITestVariableValue targetVal = GetVal(targetVar, sourceVal.Value);
63+
if (targetVal == null)
64+
{
65+
Trace.WriteLine(string.Format(" Need to create: {0}", sourceVal.Value));
66+
targetVal = targetTmc.Project.TestVariables.CreateVariableValue(sourceVal.Value);
67+
targetVar.AllowedValues.Add(targetVal);
68+
targetVar.Save();
69+
}
70+
else
71+
{
72+
Trace.WriteLine(string.Format(" Exists: {0}", targetVal.Value));
73+
}
7074
}
71-
7275

7376
}
7477
}

VSTS.DataBulkEditor.sln

+3
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ Global
5050
GlobalSection(SolutionProperties) = preSolution
5151
HideSolutionNode = FALSE
5252
EndGlobalSection
53+
GlobalSection(CodealikeProperties) = postSolution
54+
SolutionGuid = 51c92075-0694-476b-8366-efd65c9a9b77
55+
EndGlobalSection
5356
EndGlobal

0 commit comments

Comments
 (0)