コード例 #1
0
        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);
                    }
                }
            }
        }
コード例 #2
0
 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;
     });
 }
コード例 #3
0
 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;
     });
 }
コード例 #4
0
 /// <summary>
 /// Initialize the test harness.
 /// </summary>
 static App()
 {
     Harness = new TestHarness();
 }
コード例 #5
0
 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;
     });
 }