Beispiel #1
0
        /// <summary>
        /// Does the one time set up for a suite command. Broadly defined,
        /// this includes:
        ///   1. Applying changes specified by attributes to the context
        ///   2. Constructing the user fixture instance
        ///   3. Calling the one time setup methods themselves
        /// </summary>
        /// <param name="context">The execution context to use in running the test.</param>
        public virtual void DoOneTimeSetUp(TestExecutionContext context)
        {
            foreach (NUnitAttribute attr in Test.Attributes)
            {
                IApplyToContext iApply = attr as IApplyToContext;
                if (iApply != null)
                {
                    iApply.ApplyToContext(context);
                }
            }

            if (fixtureType != null)
            {
                if (context.TestObject == null && !IsStaticClass(fixtureType))
                {
                    context.TestObject = Reflect.Construct(fixtureType, arguments);
                }

                if (suite.OneTimeSetUpMethods != null)
                {
                    foreach (MethodInfo method in suite.OneTimeSetUpMethods)
                    {
                        Reflect.InvokeMethod(method, method.IsStatic ? null : context.TestObject);
                    }
                }
            }
        }
 public ApplyChangesToContextCommand(TestCommand innerCommand, IApplyToContext change)
     : base(innerCommand)
 {
     BeforeTest = (context) =>
     {
         change.ApplyToContext(context);
     };
 }
 public ApplyChangesToContextCommand(TestCommand innerCommand, IApplyToContext[] changes)
     : base(innerCommand)
 {
     _changes = changes;
 }
 public ApplyToContextCommand(TestCommand innerCommand, IApplyToContext change)
     : base(innerCommand)
 {
     _change = change;
 }