mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-04-10 03:44:18 +00:00
add patch tests and run tests on build (so fail build if tests fail)
This commit is contained in:
parent
85eb03f3c8
commit
c44ea2cc54
41
QSBTests/PatchTests.cs
Normal file
41
QSBTests/PatchTests.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using QSB.Patches;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace QSBTests
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class PatchTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void CheckUnreferencedPatches()
|
||||||
|
{
|
||||||
|
var qsbAssembly = Assembly.Load("QSB");
|
||||||
|
var allPatchTypes = qsbAssembly
|
||||||
|
.GetTypes()
|
||||||
|
.Where(x => typeof(QSBPatch).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract);
|
||||||
|
|
||||||
|
QSBPatchManager.Init();
|
||||||
|
var patchInstances = (List<QSBPatch>)typeof(QSBPatchManager)
|
||||||
|
.GetField("_patchList", BindingFlags.NonPublic | BindingFlags.Static)
|
||||||
|
.GetValue(typeof(QSBPatchManager));
|
||||||
|
|
||||||
|
var failedTypes = new List<Type>();
|
||||||
|
foreach (var type in allPatchTypes)
|
||||||
|
{
|
||||||
|
if (!patchInstances.Any(x => x.GetType() == type))
|
||||||
|
{
|
||||||
|
failedTypes.Add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failedTypes.Count > 0)
|
||||||
|
{
|
||||||
|
Assert.Fail(string.Join(", ", failedTypes.Select(x => x.Name)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -50,6 +50,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="EventTests.cs" />
|
<Compile Include="EventTests.cs" />
|
||||||
|
<Compile Include="PatchTests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="UtilityTests.cs" />
|
<Compile Include="UtilityTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -72,4 +73,7 @@
|
|||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" />
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" />
|
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEvent>dotnet test "$(SolutionDir)\QSBTests\$(OutDir)\QSBTests.dll"</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user