TestMethod
The TestMethod class represents a Test implemented as a method.
using NUnit.Framework.Interfaces;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Internal
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class TestMethod : Test
{
[System.Runtime.CompilerServices.Nullable(2)]
internal TestCaseParameters Parms;
internal bool HasExpectedResult => Parms?.HasExpectedResult ?? false;
[System.Runtime.CompilerServices.Nullable(2)]
internal object ExpectedResult {
[System.Runtime.CompilerServices.NullableContext(2)]
get {
return Parms?.ExpectedResult;
}
}
public new IMethodInfo Method {
get {
return base.Method;
}
set {
base.Method = value;
}
}
[System.Runtime.CompilerServices.Nullable(new byte[] {
1,
2
})]
public override object[] Arguments {
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
2
})]
get {
if (Parms != null)
return Parms.Arguments;
return TestParameters.NoArguments;
}
}
public override bool HasChildren => false;
public override IList<ITest> Tests => Array.Empty<ITest>();
public override string XmlElementName => "test-case";
public override string MethodName => Method.Name;
public TestMethod(IMethodInfo method)
: base(method)
{
}
public TestMethod(IMethodInfo method, [System.Runtime.CompilerServices.Nullable(2)] Test parentSuite)
: base(method)
{
if (parentSuite != null)
base.FullName = parentSuite.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;
}
}
}