2using System.Collections.Generic;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
18 public class FakeModRunner
21 public IFakeMod ActiveMod;
24 public void RunTest(
string name)
26 Assembly targetAssembly = Assembly.GetAssembly(typeof(FakeModRunner));
28 Type type = targetAssembly.GetTypes().Find(T => T.Name == name);
31 CUITest.Log($
"can't find fake mod {name}");
38 public void RunTest<RawType>() => RunTest(typeof(RawType));
40 public void RunTest(Type type)
42 if (!type.IsAssignableTo(typeof(IFakeMod)))
44 CUITest.Log($
"it's not a fake mod");
48 IFakeMod mod = (IFakeMod)Activator.CreateInstance(type);
53 public void RunTest(IFakeMod mod)
55 if (TestChamber ==
null) CUITest.CreateTestChamber();
56 if (TestChamber.Parent ==
null) CUITest.OpenTestChamber();
59 if (ActiveMod !=
null)
65 CUITest.ClearTestChamber();
69 mod.Initialize(TestChamber);
71 catch (Exception e) { CUITest.Log(e, Color.Orange); }
74 public void StopTest()
76 if (ActiveMod ==
null)
return;
78 CUITest.ClearTestChamber();
79 if (TestChamber.Parent !=
null) CUITest.CloseTestChamber();
84 public string[] FindAllFakeMods()
86 Assembly targetAssembly = Assembly.GetAssembly(typeof(FakeModRunner));
88 IEnumerable<Type> fakeModTypes = targetAssembly.GetTypes().Where(T => T.IsAssignableTo(typeof(IFakeMod)) && T != typeof(IFakeMod));
90 return fakeModTypes.Select(T => T.Name).ToArray();
93 public FakeModRunner()
Base class for all components.