<PackageReference Include="NUnit" Version="4.3.2" />

TestFixtureAttribute

Marks the class as a TestFixture.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using NUnit.Framework.Internal.Builders; using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace NUnit.Framework { [NullableContext(2)] [Nullable(0)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public class TestFixtureAttribute : NUnitAttribute, IFixtureBuilder2, IFixtureBuilder, ITestFixtureData, ITestData { [Nullable(1)] private readonly NUnitTestFixtureBuilder _builder = new NUnitTestFixtureBuilder(); private Type _testOf; public string TestName { get; set; } public RunState RunState { get; set; } [Nullable(new byte[] { 1, 2 })] [field: Nullable(new byte[] { 1, 2 })] public object[] Arguments { [return: Nullable(new byte[] { 1, 2 })] get; } [Nullable(1)] [field: Nullable(1)] public IPropertyBag Properties { [NullableContext(1)] get; } [Nullable(1)] [field: Nullable(1)] public Type[] TypeArgs { [NullableContext(1)] get; [NullableContext(1)] set; } public string Description { get { return Properties.Get("Description") as string; } [param: DisallowNull] set { Guard.ArgumentNotNull(value, "value"); Properties.Set("Description", value); } } public string Author { get { return Properties.Get("Author") as string; } [param: DisallowNull] set { Guard.ArgumentNotNull(value, "value"); Properties.Set("Author", value); } } public Type TestOf { get { return _testOf; } [param: DisallowNull] set { Guard.ArgumentNotNull(value, "value"); _testOf = value; Properties.Set("TestOf", value.FullName()); } } public string Ignore { get { return IgnoreReason; } [param: DisallowNull] set { Guard.ArgumentNotNull(value, "value"); IgnoreReason = value; } } public string Reason { get { return Properties.Get("_SKIPREASON") as string; } [param: DisallowNull] set { Guard.ArgumentNotNull(value, "value"); Properties.Set("_SKIPREASON", value); } } public string IgnoreReason { get { return Reason; } [param: DisallowNull] set { Guard.ArgumentNotNull(value, "value"); RunState = RunState.Ignored; Reason = value; } } public bool Explicit { get { return RunState == RunState.Explicit; } set { RunState = ((!value) ? RunState.Runnable : RunState.Explicit); } } public string Category { get { if (Properties.TryGet("Category", out IList values)) { switch (values.Count) { case 0: return null; case 1: return values[0] as string; default: { string[] array = new string[values.Count]; int num = 0; foreach (string item in values) { array[num++] = item; } return string.Join(",", array); } } } return null; } [param: DisallowNull] set { Guard.ArgumentNotNull(value, "value"); foreach (string item in value.Tokenize(',', false)) { Properties.Add("Category", item); } } } public TestFixtureAttribute() : this(NUnit.Framework.Internal.TestParameters.NoArguments) { } public TestFixtureAttribute(params object[] arguments) { RunState = RunState.Runnable; Arguments = (arguments ?? new object[1]); TypeArgs = Array.Empty<Type>(); Properties = new PropertyBag(); } [NullableContext(1)] public IEnumerable<TestSuite> BuildFrom(ITypeInfo typeInfo) { return BuildFrom(typeInfo, PreFilter.Empty); } [NullableContext(1)] public IEnumerable<TestSuite> BuildFrom(ITypeInfo typeInfo, IPreFilter filter) { TestSuite testSuite = _builder.BuildFrom(typeInfo, filter, this); testSuite.ApplyAttributesToTest(typeInfo.Type.Assembly.GetAttributes<FixtureLifeCycleAttribute>()); testSuite.ApplyAttributesToTest(typeInfo.Type); yield return testSuite; } } }