mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-07-31 15:58:27 -04:00
* Move all unit tests to Engine/Tests * Fix Margin.EdgeSubtract * Fix Capsule.Contains * EnvironmentVariables.Remove if it's null * Fixed ray trace never returning startedsolid * Fix HistoryList.Navigate on empty list * Fix GameObject.WorldPosition accepting NaNs * Fix flex: initial expanding to the wrong grow/shrink * Translation.TryConvert shouldn't throw on invalid enum strings * Skip sound file tests on machines with no audio device
29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis.CSharp.Testing;
|
|
using Microsoft.CodeAnalysis.Diagnostics;
|
|
using Microsoft.CodeAnalysis.Testing;
|
|
using Sandbox.CodeUpgrader;
|
|
|
|
namespace CodeUpgraderTests;
|
|
|
|
public class AnalyzerTest<T> : IAnalyzerTest where T : DiagnosticAnalyzer, new()
|
|
{
|
|
/// <summary>
|
|
/// This code should trigger the diagnostic.
|
|
/// </summary>
|
|
public async Task TestWithMarkup( string code )
|
|
{
|
|
var test = new CSharpAnalyzerTest<T, Microsoft.CodeAnalysis.Testing.DefaultVerifier>
|
|
{
|
|
ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard20,
|
|
TestCode = code,
|
|
};
|
|
|
|
test.TestState.AdditionalReferences.Add( MetadataReference.CreateFromFile( typeof( Sandbox.Internal.GlobalGameNamespace ).Assembly.Location ) );
|
|
test.TestState.AdditionalReferences.Add( MetadataReference.CreateFromFile( typeof( Sandbox.ConCmdAttribute ).Assembly.Location ) );
|
|
test.TestState.AdditionalReferences.Add( MetadataReference.CreateFromFile( typeof( NetFlags ).Assembly.Location ) );
|
|
|
|
await test.RunAsync();
|
|
}
|
|
}
|