示例#1
0
        /// <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();
                }
            }
        }
示例#2
0
        public void Draw()
        {
            TestContext  testContext  = this.context;
            ExitCriteria exitCriteria = testContext.ExitCriteria;

            if (exitCriteria != null)
            {
                DrawExitCriteria(testContext, exitCriteria);
            }
        }
示例#3
0
 private static bool DrawExitCriteria(TestContext testContext, ExitCriteria exitCriteria)
 {
     if (!exitCriteria.IsFinished)
     {
         exitCriteria.Draw();
         return(true);
     }
     else
     {
         testContext.ExitCriteria = null;
         return(false);
     }
 }
示例#4
0
        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);
            }
        }
示例#5
0
 private static bool UpdateExitCriteria(TimeSpan elapsedGameTime, TestContext testContext, ExitCriteria exitCriteria)
 {
     if (!exitCriteria.IsFinished)
     {
         exitCriteria.Update(elapsedGameTime);
         return(true);
     }
     else
     {
         testContext.ExitCriteria = null;
         return(false);
     }
 }