public void StartRun(TestHarness harness)
 {
     Dispatcher.BeginInvoke(() =>
     {
         lblCurrentTestNumber.Text = harness.Progress.ToString();
         lblTotalTestNumber.Text = harness.Count.ToString();
         lblFailureNumber.Tag = harness.Failures.ToString() ?? "0";
         progress.Value = 1;
     });
 }
 public void EndRun(TestHarness harness)
 {
     Dispatcher.BeginInvoke(() =>
     {
         if (harness.Failures > 0)
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0}/{1} tests failed!", harness.Failures, harness.Count);
             lblResults.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x6E));
         }
         else
         {
             lblResults.Text = string.Format(CultureInfo.InvariantCulture, "{0} tests passed!", harness.Count);
         }
         lblResults.Visibility = Visibility.Visible;
     });
 }
        public static void Populate(TestHarness harness)
        {
            //Assembly assembly = typeof(TestDiscovery).GetTypeInfo().Assembly;
            //Dictionary<TypeInfo, TestGroup> groups = new Dictionary<TypeInfo, TestGroup>();
            Assembly assembly = typeof(TestDiscovery).Assembly;
            Dictionary<Type, TestGroup> groups = new Dictionary<Type, TestGroup>();
            Dictionary<TestGroup, object> instances = new Dictionary<TestGroup, object>();
            //foreach (TypeInfo type in assembly.DefinedTypes)
            foreach (Type type in assembly.GetTypes())
            {
                //foreach (MethodInfo method in type.DeclaredMethods)
                foreach (MethodInfo method in type.GetMethods())
                {
                    if (method.GetCustomAttribute<TestMethodAttribute>(true) != null ||
                        method.GetCustomAttribute<AsyncTestMethodAttribute>(true) != null)
                    {
                        TestGroup group = null;
                        object instance = null;
                        if (!groups.TryGetValue(type, out group))
                        {
                            group = CreateGroup(type);
                            harness.Groups.Add(group);
                            groups[type] = group;

                            //instance = Activator.CreateInstance(type.AsType());
                            instance = Activator.CreateInstance(type);
                            instances[group] = instance;
                        }
                        else
                        {
                            instances.TryGetValue(group, out instance);
                        }

                        TestMethod test = CreateMethod(type, instance, method);
                        group.Methods.Add(test);
                    }
                }
            }
        }
 /// <summary>
 /// Initialize the test harness.
 /// </summary>
 static App()
 {
     Harness = new TestHarness();
 }
 public void Progress(TestHarness harness)
 {
     Dispatcher.BeginInvoke(() =>
     {
         lblCurrentTestNumber.Text = harness.Progress.ToString();
         lblFailureNumber.Text = " " + (harness.Failures.ToString() ?? "0");
         double value = harness.Progress;
         int count = harness.Count;
         if (count > 0)
         {
             value = value * 100.0 / (double)count;
         }
         progress.Value = value;
     });
 }