<PackageReference Include="NUnit" Version="3.0.0-alpha-2" />

SetUpFixtureAttribute

SetUpFixtureAttribute is used to identify a SetUpFixture
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using System; using System.Reflection; namespace NUnit.Framework { [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class SetUpFixtureAttribute : FixtureBuilderAttribute, IFixtureBuilder { public TestSuite BuildFrom(Type type) { SetUpFixture setUpFixture = new SetUpFixture(type); if (setUpFixture.RunState != 0) { string reason = null; if (!IsValidFixtureType(type, ref reason)) { setUpFixture.RunState = RunState.NotRunnable; setUpFixture.Properties.Set("_SKIPREASON", reason); } } return setUpFixture; } private bool IsValidFixtureType(Type fixtureType, ref string reason) { if (fixtureType.IsAbstract) { reason = $"{fixtureType.FullName}"""; return false; } if (fixtureType.GetConstructor(new Type[0]) == (ConstructorInfo)null) { reason = $"{fixtureType.FullName}"""; return false; } Type[] array = new Type[4] { typeof(SetUpAttribute), typeof(TearDownAttribute), typeof(TestFixtureSetUpAttribute), typeof(TestFixtureTearDownAttribute) }; Type[] array2 = array; foreach (Type type in array2) { if (Reflect.HasMethodWithAttribute(fixtureType, type)) { reason = type.Name + " attribute not allowed in a SetUpFixture"; return false; } } return true; } } }