Ejemplo n.º 1
0
 private object EvaluateVariable(ITestVariable variable)
 {
     lock (locker)
     {
         if (!variable.IsEvaluated())
         {
             variable.Evaluate();
         }
     }
     return(variable.GetValue());
 }
Ejemplo n.º 2
0
        private object EvaluateVariable(ITestVariable variable)
        {
            if (!variable.IsEvaluated())
            {
                var stopWatch = new Stopwatch();
                stopWatch.Start();
                variable.GetValue();
                Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, $"Time needed for evaluation of variable '{args.VariableName}': {stopWatch.Elapsed.ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s")}");
            }

            var output = variable.GetValue();

            return(output);
        }
Ejemplo n.º 3
0
        // http://blogs.microsoft.co.il/shair/2015/02/02/tfs-api-part-56-test-configurations/
        protected override void InternalExecute()
        {
            TestManagementContext SourceTmc  = new TestManagementContext(Engine.Source);
            TestManagementContext targetTmc  = new TestManagementContext(Engine.Target);
            List <ITestVariable>  sourceVars = SourceTmc.Project.TestVariables.Query().ToList();

            Log.LogInformation("Plan to copy {0} Veriables?", sourceVars.Count);

            foreach (var sourceVar in sourceVars)
            {
                Log.LogInformation("Copy: {0}", sourceVar.Name);
                ITestVariable targetVar = GetVar(targetTmc.Project.TestVariables, sourceVar.Name);
                bool          isDirty   = false;
                if (targetVar == null)
                {
                    Log.LogInformation("    Need to create: {0}", sourceVar.Name);
                    targetVar      = targetTmc.Project.TestVariables.Create();
                    targetVar.Name = sourceVar.Name;
                    isDirty        = true;
                }
                else
                {
                    Log.LogInformation("    Exists: {0}", sourceVar.Name);
                }
                // match values
                foreach (var sourceVal in sourceVar.AllowedValues)
                {
                    Log.LogInformation("    Seeking: {0}", sourceVal.Value);
                    ITestVariableValue targetVal = GetVal(targetVar, sourceVal.Value);
                    if (targetVal == null)
                    {
                        Log.LogInformation("    Need to create: {0}", sourceVal.Value);
                        targetVal = targetTmc.Project.TestVariables.CreateVariableValue(sourceVal.Value);
                        targetVar.AllowedValues.Add(targetVal);
                        isDirty = true;
                    }
                    else
                    {
                        Log.LogInformation("    Exists: {0}", targetVal.Value);
                    }
                }
                if (isDirty)
                {
                    targetVar.Save();
                }
            }
        }
Ejemplo n.º 4
0
        internal override void InternalExecute()
        {
            WorkItemStoreContext  sourceWisc = new WorkItemStoreContext(me.Source, WorkItemStoreFlags.None);
            TestManagementContext SourceTmc  = new TestManagementContext(me.Source);

            WorkItemStoreContext  targetWisc = new WorkItemStoreContext(me.Target, WorkItemStoreFlags.BypassRules);
            TestManagementContext targetTmc  = new TestManagementContext(me.Target);

            List <ITestVariable> sourceVars = SourceTmc.Project.TestVariables.Query().ToList();

            Trace.WriteLine(string.Format("Plan to copy {0} Veriables?", sourceVars.Count));

            foreach (var sourceVar in sourceVars)
            {
                Trace.WriteLine(string.Format("Copy: {0}", sourceVar.Name));
                ITestVariable targetVar = GetVar(targetTmc.Project.TestVariables, sourceVar.Name);
                if (targetVar == null)
                {
                    Trace.WriteLine(string.Format("    Need to create: {0}", sourceVar.Name));
                    targetVar      = targetTmc.Project.TestVariables.Create();
                    targetVar.Name = sourceVar.Name;
                    targetVar.Save();
                }
                else
                {
                    Trace.WriteLine(string.Format("    Exists: {0}", sourceVar.Name));
                }
                // match values
                foreach (var sourceVal in sourceVar.AllowedValues)
                {
                    Trace.WriteLine(string.Format("    Seeking: {0}", sourceVal.Value));
                    ITestVariableValue targetVal = GetVal(targetVar, sourceVal.Value);
                    if (targetVal == null)
                    {
                        Trace.WriteLine(string.Format("    Need to create: {0}", sourceVal.Value));
                        targetVal = targetTmc.Project.TestVariables.CreateVariableValue(sourceVal.Value);
                        targetVar.AllowedValues.Add(targetVal);
                        targetVar.Save();
                    }
                    else
                    {
                        Trace.WriteLine(string.Format("    Exists: {0}", targetVal.Value));
                    }
                }
            }
        }
Ejemplo n.º 5
0
 internal ITestVariableValue GetVal(ITestVariable targetVar, string valueToFind)
 {
     // Test Variable values are case insensitive in VSTS so need ignore case in comparison
     return(targetVar.AllowedValues.FirstOrDefault(
                variable => string.Equals(variable.Value, valueToFind, StringComparison.OrdinalIgnoreCase)));
 }
Ejemplo n.º 6
0
 internal ITestVariableValue GetVal(ITestVariable targetVar, string valueToFind)
 {
     return((from tv in targetVar.AllowedValues where tv.Value == valueToFind select tv).SingleOrDefault());
 }