ParameterSet
ParameterSet encapsulates method arguments and
other selected parameters needed for constructing
a parameterized test case.
using NUnit.Framework.Interfaces;
using System;
namespace NUnit.Framework.Internal
{
public class ParameterSet : ITestCaseData, IApplyToTest
{
private object _expectedResult;
public RunState RunState { get; set; }
public object[] Arguments { get; set; }
public object ExpectedResult {
get {
return _expectedResult;
}
set {
_expectedResult = value;
HasExpectedResult = true;
}
}
public bool HasExpectedResult { get; set; }
public string TestName { get; set; }
public IPropertyBag Properties { get; set; }
public object[] OriginalArguments { get; set; }
public ParameterSet()
{
RunState = RunState.Runnable;
Properties = new PropertyBag();
}
public ParameterSet(Exception exception)
{
RunState = RunState.NotRunnable;
Properties = new PropertyBag();
Properties.Set("_SKIPREASON", ExceptionHelper.BuildMessage(exception));
Properties.Set("_PROVIDERSTACKTRACE", ExceptionHelper.BuildStackTrace(exception));
}
public ParameterSet(object[] args)
: this()
{
object[] array3 = Arguments = (OriginalArguments = args);
}
public ParameterSet(ITestCaseData data)
{
TestName = data.TestName;
RunState = data.RunState;
object[] array2 = Arguments = (OriginalArguments = data.Arguments);
if (data.HasExpectedResult)
ExpectedResult = data.ExpectedResult;
Properties = new PropertyBag();
foreach (string key in data.Properties.Keys) {
Properties[key] = data.Properties[key];
}
}
public void ApplyToTest(Test test)
{
if (RunState != RunState.Runnable)
test.RunState = RunState;
foreach (string key in Properties.Keys) {
foreach (object item in Properties[key]) {
test.Properties.Add(key, item);
}
}
}
}
}