using OpenTap.Addin.Util;
|
using OpenTap;
|
using OpenTap.Addin;
|
using OpenTap.Addin.Annotation;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.ComponentModel;
|
using OpenTap.Addin.Entity;
|
|
namespace AddInPlugin
|
{
|
[Browsable(false)]
|
public abstract class VariableTestStep : TestStep
|
{
|
protected ObservableCollection<MethodVariable> methodVariables = new ObservableCollection<MethodVariable>();
|
[Display("参数", Order: 0.0, Description: "运行参数.")]
|
[BindingList(nameof(MethodVariables))]
|
public virtual ObservableCollection<MethodVariable> MethodVariables
|
{
|
get => methodVariables;
|
set
|
{
|
methodVariables = value;
|
foreach (var mv in value)
|
{
|
mv.Type = Type.GetType(mv.TypeName);
|
}
|
OnPropertyChanged(nameof(MethodVariables));
|
OnMethodVariablesChanged(value);
|
}
|
}
|
|
protected virtual void OnMethodVariablesChanged(ObservableCollection<MethodVariable> variables)
|
{
|
|
}
|
|
public override void PrePlanRun()
|
{
|
base.PrePlanRun();
|
}
|
|
protected virtual void UpdateVariableToRuntime()
|
{
|
//if (IsConstructorMethod)
|
//{
|
// var methodVariable = MethodVariables[0];
|
// PlanRun.UpdateRuntimeVariable(methodVariable.ValueStr, instance);
|
//}
|
foreach (var mv in MethodVariables)
|
{
|
if (EnableReport)
|
{
|
if (mv.Log)
|
{
|
var detail = new ReportDetail
|
{
|
Name = mv.Name,
|
};
|
try
|
{
|
detail.Type = mv.Type.Name;
|
detail.Normal = true;
|
detail.Value = mv.Value?.ToString();
|
}
|
catch (Exception ex)
|
{
|
detail.Normal = false;
|
detail.Exception = ex;
|
}
|
StepRun.Report.Details.Add(detail);
|
}
|
}
|
|
if (mv.Direction == VariableDirection.Out && !string.IsNullOrEmpty(mv.ValueStr))
|
{
|
PlanRun.Update(this, mv.ValueStr, mv.Value);
|
}
|
}
|
}
|
}
|
}
|