public static void Populate(TestHarness harness)
        {
            Assembly assembly = typeof(TestDiscovery).GetTypeInfo().Assembly;
            Dictionary<TypeInfo, TestGroup> groups = new Dictionary<TypeInfo, TestGroup>();
            Dictionary<TestGroup, object> instances = new Dictionary<TestGroup, object>();
            foreach (TypeInfo type in assembly.DefinedTypes)
            {
                foreach (MethodInfo method in type.DeclaredMethods)
                {
                    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());
                            instances[group] = instance;
                        }
                        else
                        {
                            instances.TryGetValue(group, out instance);
                        }

                        TestMethod test = CreateMethod(type, instance, method);
                        group.Methods.Add(test);
                    }
                }
            }
        }
        public async void StartRun(TestHarness harness)
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {

                lblCurrentTestNumber.Text = harness.Progress.ToString();
                lblTotalTestNumber.Text = harness.Count.ToString();
                lblFailureNumber.Tag = harness.Failures.ToString() ?? "0";
                progress.Value = 1;
                pnlFooter.Visibility = Visibility.Visible;
            });
        }
 public async void Progress(TestHarness harness)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         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;
     });
 }
 public async void EndRun(TestHarness harness)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         pnlFooter.Visibility = Visibility.Collapsed;
         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;
     });
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initialize the test harness.
 /// </summary>
 static App()
 {
     Harness = new TestHarness();
 }