/// <summary> /// This will be called before the actual assert method. Executes all methods in the context marked with the <see cref="PrerequisiteAttribute"/>. /// </summary> protected void RunPrerequisites() { var prerequisiteTestsToRun = TypeInvestigationService.GetPrerequisiteTestMethods(this.contextType); foreach (var prerequisiteTest in prerequisiteTestsToRun) { try { prerequisiteTest.Invoke(this, BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic, null, null, CultureInfo.InvariantCulture); } catch (TargetInvocationException ex) { var exception = ex.InnerException; if (exception is AssertionException && exception.Message.TrimStart().StartsWith("Expected")) { var message = string.Format("{0}.{1}\r\n{2}", this.contextType.Name, prerequisiteTest.Name, exception.Message); exception = new PrerequisiteFailureException(message); throw exception; } throw ExceptionEnlightenment.PrepareForRethrow(exception); } } }
/// <summary> /// This will be called before the actual assert method. Executes all methods in the context marked with the <see cref="PrerequisiteAttribute"/>. /// </summary> protected void RunPrerequisites() { var prerequisiteTestsToRun = TypeInvestigationService.GetPrerequisiteTestMethods(this.contextType); foreach (var prerequisiteTest in prerequisiteTestsToRun) { try { prerequisiteTest.Invoke(this, BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic, null, null, CultureInfo.InvariantCulture); } catch (TargetInvocationException ex) { var exception = ex.InnerException; if (exception is AssertionException && exception.Message.TrimStart().StartsWith("Expected")) { var message = string.Format("{0}.{1}\r\n{2}", this.contextType.Name, prerequisiteTest.Name, exception.Message); exception = new PrerequisiteFailureException(message); throw exception; } throw ExceptionEnlightenment.PrepareForRethrow(exception); } } }