CrabUI
Loading...
Searching...
No Matches
ComponentTest.cs
1using System;
2using System.Reflection;
3using System.Runtime.CompilerServices;
4using System.Collections.Generic;
5using System.Collections.Immutable;
6using System.Linq;
7
8using Barotrauma;
9using HarmonyLib;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Graphics;
12
13using CrabUI;
14
15namespace CrabUITest
16{
17 /// <summary>
18 /// Testing the overall behavior of a component
19 /// </summary>
20 public partial class ComponentTest : FillMethods
21 {
22
23
24 public static void PrintCoverage()
25 {
26 Assembly targetAssembly = Assembly.GetAssembly(typeof(ComponentTest));
27
28 IEnumerable<Type> componentTypes = targetAssembly.GetTypes().Where(T => T.IsSubclassOf(typeof(CUIComponent)) && T.DeclaringType == null);
29
30 IEnumerable<MethodInfo> testMethods = typeof(ComponentTest).GetMethods().Where(mi => FillMethods.IsTestMethod(mi));
31
32 Dictionary<string, bool> IsCovered = new Dictionary<string, bool>();
33
34 foreach (MethodInfo mi in testMethods)
35 {
36 IsCovered[mi.Name] = true;
37 }
38
39 foreach (Type T in componentTypes)
40 {
41 bool covered = IsCovered.GetValueOrDefault(T.Name);
42 Color cl = covered ? Color.Lime : Color.Red;
43 CUITest.Log(T, cl);
44 }
45 }
46
47 }
48}
Base class for all components.