public void InitializeContext(UnityTestExecutionContext context) { Context = context; if (Test is TestAssembly) { Actions.AddRange(ActionsHelper.GetActionsFromTestAssembly((TestAssembly)Test)); } else if (Test is ParameterizedMethodSuite) { Actions.AddRange(ActionsHelper.GetActionsFromTestMethodInfo(Test.Method)); } else if (Test.TypeInfo != null) { Actions.AddRange(ActionsHelper.GetActionsFromTypesAttributes(Test.TypeInfo.Type)); } }
/// <summary> /// Initialize the TestExecutionContext. This must be done /// before executing the WorkItem. /// </summary> /// <remarks> /// Originally, the context was provided in the constructor /// but delaying initialization of the context until the item /// is about to be dispatched allows changes in the parent /// context during OneTimeSetUp to be reflected in the child. /// </remarks> /// <param name="context">The TestExecutionContext to use</param> public void InitializeContext(TestExecutionContext context) { Guard.OperationValid(Context == null, "The context has already been initialized"); Context = context; if (Test is TestAssembly) { Actions.AddRange(ActionsHelper.GetActionsFromAttributeProvider(((TestAssembly)Test).Assembly)); } else if (Test is ParameterizedMethodSuite) { Actions.AddRange(ActionsHelper.GetActionsFromAttributeProvider(Test.Method.MethodInfo)); } else if (Test.TypeInfo != null) { Actions.AddRange(ActionsHelper.GetActionsFromTypesAttributes(Test.TypeInfo.Type)); } }