/// <summary> /// This will run all tests that have been marked accordingly. /// </summary> /// <typeparam name="HostType">The test runner will look in the assembly of this Type.</typeparam> /// <param name="context">The test context that will be passed to all test methods.</param> public static void RunTests(TestContext context) { Type currentType = null; object currentObject = null; foreach (MethodInfo method in FindTestMethods()) { if (method.DeclaringType != currentType) { currentObject = Activator.CreateInstance(method.DeclaringType); currentType = method.DeclaringType; } ExecuteMethod(currentObject, method, context); if (context.ExitCriteria != null) { ExitCriteria exit = context.ExitCriteria; while (!exit.IsFinished) { // TODO: this blocks the main thread, should let the caller drive // further updates. UpdateExitCriteria(new TimeSpan(0, 0, 0, 0, 16), context, exit); DrawExitCriteria(context, exit); } Assert.Reporter.End(); } } }
public void Draw() { TestContext testContext = this.context; ExitCriteria exitCriteria = testContext.ExitCriteria; if (exitCriteria != null) { DrawExitCriteria(testContext, exitCriteria); } }
private static bool DrawExitCriteria(TestContext testContext, ExitCriteria exitCriteria) { if (!exitCriteria.IsFinished) { exitCriteria.Draw(); return(true); } else { testContext.ExitCriteria = null; return(false); } }
public void Update(TimeSpan elapsedGameTime) { TestContext testContext = this.context; ExitCriteria exitCriteria = testContext.ExitCriteria; if (exitCriteria != null) { UpdateExitCriteria(elapsedGameTime, testContext, exitCriteria); } else if (enumerator.MoveNext()) { MethodInfo method = enumerator.Current; if (method.DeclaringType != currentType) { currentObject = Activator.CreateInstance(method.DeclaringType); currentType = method.DeclaringType; } ExecuteMethod(currentObject, method, testContext); } }
private static bool UpdateExitCriteria(TimeSpan elapsedGameTime, TestContext testContext, ExitCriteria exitCriteria) { if (!exitCriteria.IsFinished) { exitCriteria.Update(elapsedGameTime); return(true); } else { testContext.ExitCriteria = null; return(false); } }