TestMethod
The TestMethod class represents a Test implemented as a method.
using NUnit.Framework.Interfaces;
using System.Collections.Generic;
using System.Reflection;
namespace NUnit.Framework.Internal
{
public class TestMethod : Test
{
internal TestCaseParameters parms;
internal bool HasExpectedResult {
get {
if (parms != null)
return parms.HasExpectedResult;
return false;
}
}
internal object ExpectedResult {
get {
if (parms == null)
return null;
return parms.ExpectedResult;
}
}
internal object[] Arguments {
get {
if (parms == null)
return null;
return parms.Arguments;
}
}
public override bool HasChildren => false;
public override IList<ITest> Tests => new ITest[0];
public override string XmlElementName => "test-case";
public override string MethodName => base.Method.Name;
public TestMethod(MethodInfo method)
: this(method, null)
{
}
public TestMethod(MethodInfo method, Test parentSuite)
: base(method)
{
string fullName = method.ReflectedType.FullName;
if (parentSuite != null) {
fullName = parentSuite.FullName;
base.FullName = fullName + "." + base.Name;
}
}
public override TestResult MakeTestResult()
{
return new TestCaseResult(this);
}
public override TNode AddToXml(TNode parentNode, bool recursive)
{
TNode tNode = parentNode.AddElement(XmlElementName);
PopulateTestNode(tNode, recursive);
tNode.AddAttribute("seed", base.Seed.ToString());
return tNode;
}
}
}