using AddInPlugin.Util;
|
using OpenTap;
|
using System;
|
|
namespace AddInPlugin
|
{
|
[Display("Break", Group: "流程控制", Order: 0)]
|
[AllowAsChildIn(typeof(CanBreakBase))]
|
public class BreakStep : TestStep
|
{
|
private string condition;
|
[Display("条件")]
|
public string Condition
|
{
|
get => condition;
|
set
|
{
|
condition = value;
|
OnPropertyChanged(nameof(Condition));
|
}
|
}
|
|
public BreakStep() : base()
|
{
|
Rules.Add(() => GetParent<CanBreakBase>() != null, "必须在CanBreak中", Name);
|
}
|
|
public override void Run()
|
{
|
try
|
{
|
bool needBreak = false;
|
if (string.IsNullOrEmpty(Condition))
|
{
|
needBreak = true;
|
}
|
else if (PlanRun.Resolve<bool>(this, Condition))
|
{
|
needBreak = true;
|
}
|
if (needBreak)
|
{
|
var target = this.GetParent<CanBreakBase>();
|
if (target == null)
|
{
|
throw new Exception("Structure Error");
|
}
|
target.IsBreaked = true;
|
UpgradeVerdict(Verdict.NotSet);
|
}
|
}
|
catch (Exception ex)
|
{
|
Log.Error("For Run error. {0}", ex);
|
UpgradeVerdict(Verdict.Error);
|
}
|
}
|
|
public override void PostPlanRun()
|
{
|
}
|
}
|
}
|