Make tests run on .NET Core as well (#6997)

* Make tests run on .NET Core as well

* Only run net461 tests against full framework build

* Add support for running full framework tests on linux
This commit is contained in:
junglebus
2020-01-23 04:42:23 +11:00
committed by garfield69
parent 5bd4f7c364
commit 620a09858c
3 changed files with 17 additions and 16 deletions

View File

@@ -76,7 +76,7 @@ Task("Run-Unit-Tests")
CreateDirectory("./" + testResultsDirName);
var resultsFile = $"./{testResultsDirName}/JackettTestResult.xml";
NUnit3("./src/**/bin/" + configuration + "/**/*.Test.dll", new NUnit3Settings
NUnit3("./src/**/bin/" + configuration + "/net461/*.Test.dll", new NUnit3Settings
{
Results = new[] { new NUnit3Result { FileName = resultsFile } }
});

View File

@@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<IsPackable>false</IsPackable>
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@@ -29,7 +27,7 @@
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
</ItemGroup>
<ItemGroup>
@@ -40,8 +38,10 @@
<ProjectReference Include="..\Jackett.Common\Jackett.Common.csproj" />
<ProjectReference Include="..\Jackett.Server\Jackett.Server.csproj" />
</ItemGroup>
<ItemGroup>
<!-- Conditionally obtain references for the .NET461 target -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
<Reference Include="System.Web" />
</ItemGroup>

View File

@@ -1,4 +1,5 @@
using System.Text;
using System;
using System.Text;
using System.Web;
using Jackett.Common.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -13,6 +14,14 @@ namespace Jackett.Test
public WebUtilityHelpersTests()
{
//https://docs.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=netcore-2.0
#if !NET461
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
#endif
_codePagesToTest = new Encoding[]{
Encoding.UTF8,
Encoding.ASCII,
@@ -28,14 +37,6 @@ namespace Jackett.Test
"Å[ÉfÉBÉìÉOÇÕìÔǵÇ≠ǻǢ",
"J͖ͥͨ̑͂̄̈́ḁ̹ͧͦ͡ͅc̲̗̮͍̻͓ͤk̳̥̖͗ͭ̾͌e̖̲̟̽ț̠͕͈͓͎̱t͕͕͓̹̹ͫͧ̆͑ͤ͝ ̼͓̟̣͔̇̒T̻̺̙̣̘͔̤̅͒̈̈͛̅e̥̗̍͟s̖̬̭͈̠t̫̩͙̯̩ͣ̏̕ ̸̰̬̄̀ͧ̀S̨̻̼̜̹̼͓̺ͨ̍ͦt͇̻̺̂́̄͌͗̕r̥͈̙͙̰͈̙͗̆̽̀i͉͔̖̻̹̗̣̍ͭ̒͗n̴̻͔̹̘̱̳͈͐ͦ̃̽͐̓̂g̴͚͙̲ͩ͌̆̉̀̾"
};
//https://docs.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=netcore-2.0
#if !NET461
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
#endif
}