本文整理汇总了C#中IEvaluator.Evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# IEvaluator.Evaluate方法的具体用法?C# IEvaluator.Evaluate怎么用?C# IEvaluator.Evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvaluator
的用法示例。
在下文中一共展示了IEvaluator.Evaluate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Verify
public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
CommandCallList childCommands = commandCall.Children;
childCommands.SetUp(evaluator, resultRecorder);
childCommands.Execute(evaluator, resultRecorder);
childCommands.Verify(evaluator, resultRecorder);
String expression = commandCall.Expression;
Object result = evaluator.Evaluate(expression);
if (result != null && result is Boolean)
{
if ((Boolean) result)
{
ProcessTrueResult(commandCall, resultRecorder);
}
else
{
ProcessFalseResult(commandCall, resultRecorder);
}
}
else
{
throw new InvalidExpressionException("Expression '" + expression + "' did not produce a boolean result (needed for assertTrue).");
}
}
示例2: Evaluate
private static double[] Evaluate(IEvaluator evaluator, Function[] functions)
{
List<double> values = new List<double>();
foreach (Function function in functions)
{
values.Add(evaluator.Evaluate(function));
}
return values.ToArray();
}
示例3: Execute
public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside a 'run' is not supported");
var element = commandCall.Element;
var href = element.GetAttributeValue("href");
Check.NotNull(href, "The 'href' attribute must be set for an element containing concordion:run");
var runnerType = commandCall.Expression;
var expression = element.GetAttributeValue("params", "concordion");
if (expression != null)
{
evaluator.Evaluate(expression);
}
try
{
IRunner concordionRunner;
Runners.TryGetValue(runnerType, out concordionRunner);
// TODO - re-check this.
Check.NotNull(concordionRunner, "The runner '" + runnerType + "' cannot be found. "
+ "Choices: (1) Use 'concordion' as your runner (2) Ensure that the 'concordion.runner." + runnerType
+ "' System property is set to a name of an IRunner implementation "
+ "(3) Specify an assembly fully qualified class name of an IRunner implementation");
var result = concordionRunner.Execute(evaluator.Fixture, commandCall.Resource, href).Result;
if (result == Result.Success)
{
resultRecorder.Success();
AnnounceSuccess(element);
}
else if (result == Result.Ignored)
{
resultRecorder.Ignore();
AnnounceIgnored(element);
}
else
{
resultRecorder.Failure(string.Format("test {0} failed", href), commandCall.Element.ToXml());
AnnounceFailure(element);
}
}
catch (Exception e)
{
resultRecorder.Error(e);
AnnounceError(e, element, expression);
}
}
示例4: Verify
public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
var pattern = new Regex("(#.+?) *: *(.+)");
var matcher = pattern.Match(commandCall.Expression);
if (!matcher.Success)
{
throw new InvalidOperationException("The expression for a \"verifyRows\" should be of the form: #var : collectionExpr");
}
var loopVariableName = matcher.Groups[1].Value;
var iterableExpression = matcher.Groups[2].Value;
var obj = evaluator.Evaluate(iterableExpression);
Check.NotNull(obj, "Expression returned null (should be an IEnumerable).");
Check.IsTrue(obj is IEnumerable, obj.GetType() + " is not IEnumerable");
Check.IsTrue(!(obj is IDictionary), obj.GetType() + " does not have a predictable iteration order");
var iterable = (IEnumerable)obj;
var tableSupport = new TableSupport(commandCall);
var detailRows = tableSupport.GetDetailRows();
AnnounceExpressionEvaluated(commandCall.Element);
int index = 0;
foreach (var loopVar in iterable)
{
evaluator.SetVariable(loopVariableName, loopVar);
Row detailRow;
if (detailRows.Count > index)
{
detailRow = detailRows[index];
}
else
{
detailRow = tableSupport.AddDetailRow();
AnnounceSurplusRow(detailRow.RowElement);
}
tableSupport.CopyCommandCallsTo(detailRow);
commandCall.Children.Verify(evaluator, resultRecorder);
index++;
}
for (; index < detailRows.Count; index++) {
Row detailRow = detailRows[index];
resultRecorder.Record(Result.Failure);
AnnounceMissingRow(detailRow.RowElement);
}
}
示例5: Verify
public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'echo' is not supported");
Object result = evaluator.Evaluate(commandCall.Expression);
Element element = commandCall.Element;
if (result != null)
{
element.AppendText(result.ToString());
}
else
{
Element child = new Element("em");
child.AppendText("null");
element.AppendChild(child);
}
}
示例6: Verify
public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'assertEquals' is not supported");
Element element = commandCall.Element;
object actual = evaluator.Evaluate(commandCall.Expression);
string expected = element.Text;
if (m_comparer.Compare(actual, expected) == 0)
{
resultRecorder.Record(Result.Success);
OnSuccessReported(element);
}
else
{
resultRecorder.Record(Result.Failure);
OnFailureReported(element, actual, expected);
}
}
示例7: Verify
public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
{
Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'assertEquals' is not supported");
Element element = commandCall.Element;
object actual = evaluator.Evaluate(commandCall.Expression);
string expected = element.Text;
if (this.m_Comparer.Compare(actual, expected) == 0)
{
resultRecorder.Success();
AnnounceSuccess(element);
}
else
{
resultRecorder.Failure(string.Format("expected {0} but was {1}", expected, actual),
element.ToXml());
AnnounceFailure(element, expected, actual);
}
}
示例8: Test
protected override bool Test (IEvaluator condition, State state, ref bool currentState) {
currentState = condition.Evaluate(state) || _startState;
return(!currentState);
}
示例9: Value
/// <summary>
/// Evaluates the function by assigning values to the variables.
/// </summary>
public double Value(IEvaluator evaluator)
{
// Consider removing this extra call?
return evaluator.Evaluate(this);
}