Skip to content

Commit 8090219

Browse files
Merge pull request #323 from icsharpcode/update-unit-tests
Fix unit testing for netcore3.1 and net6.0 targets.
2 parents 953c924 + 17eafc3 commit 8090219

File tree

4 files changed

+52
-7
lines changed

4 files changed

+52
-7
lines changed

.github/workflows/dotnet.yml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,70 @@ jobs:
2626
version: ${{ env.BuildVersion }}.${{ github.run_number }}
2727
assemblyVersion: ${{ env.BuildVersion }}.${{ github.run_number }}
2828
fileVersion: ${{ env.BuildVersion }}.${{ github.run_number }}
29+
30+
- name: Setup .NET 3.1 (for unit tests only)
31+
uses: actions/setup-dotnet@v1
32+
with:
33+
dotnet-version: 3.1.x
34+
2935
- name: Setup .NET
3036
uses: actions/setup-dotnet@v1
3137
with:
3238
dotnet-version: 6.0.x
33-
- name: Setup NuGet.exe
34-
uses: nuget/setup-nuget@v1
35-
- run: nuget restore ICSharpCode.AvalonEdit.sln
39+
40+
- name: Add msbuild to PATH
41+
uses: microsoft/[email protected]
42+
43+
- run: msbuild ICSharpCode.AvalonEdit.sln /t:Restore /p:Configuration=${{ matrix.configuration }}
44+
3645
- name: Build
37-
run: dotnet build ICSharpCode.AvalonEdit.sln --no-restore -c ${{ matrix.configuration }}
38-
- name: Test
39-
run: dotnet test ICSharpCode.AvalonEdit.sln --no-build --verbosity normal -c ${{ matrix.configuration }}
46+
run: msbuild ICSharpCode.AvalonEdit.sln /p:Configuration=${{ matrix.configuration }}
47+
48+
- name: Setup VSTest
49+
uses: Malcolmnixon/Setup-VSTest@v4
50+
51+
- name: net6.0-windows Unit Tests
52+
run: vstest.console $env:TestAssembly
53+
env:
54+
TestAssembly: ICSharpCode.AvalonEdit.Tests\bin\${{ matrix.configuration }}\net6.0-windows\ICSharpCode.AvalonEdit.Tests.dll
55+
56+
- name: netcoreapp3.1 Unit Tests
57+
run: vstest.console $env:TestAssembly
58+
env:
59+
TestAssembly: ICSharpCode.AvalonEdit.Tests\bin\${{ matrix.configuration }}\netcoreapp3.1\ICSharpCode.AvalonEdit.Tests.dll
60+
61+
- name: net45 Unit Tests
62+
run: vstest.console $env:TestAssembly
63+
env:
64+
TestAssembly: ICSharpCode.AvalonEdit.Tests\bin\${{ matrix.configuration }}\net45\ICSharpCode.AvalonEdit.Tests.dll
65+
66+
- name: net40 Unit Tests
67+
run: vstest.console $env:TestAssembly
68+
env:
69+
TestAssembly: ICSharpCode.AvalonEdit.Tests\bin\${{ matrix.configuration }}\net40\ICSharpCode.AvalonEdit.Tests.dll
70+
4071
- name: Style - tab check
4172
run: python BuildTools\tidy.py
73+
4274
- name: Pack
43-
run: dotnet pack ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj -c ${{ matrix.configuration }}
75+
run: dotnet pack ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj -c ${{ matrix.configuration }}
76+
4477
- name: Upload NuGet
4578
if: matrix.configuration == 'release'
4679
uses: actions/upload-artifact@v2
4780
with:
4881
name: AvalonEdit NuGet Package (${{ matrix.configuration }})
4982
path: ICSharpCode.AvalonEdit/bin/Release/AvalonEdit*.nupkg
5083
if-no-files-found: error
84+
85+
- name: Upload Snupkg Artifact
86+
if: matrix.configuration == 'release'
87+
uses: actions/upload-artifact@v2
88+
with:
89+
name: AvalonEdit Snupkg (${{ matrix.configuration }})
90+
path: ICSharpCode.AvalonEdit/bin/Release/AvalonEdit*.snupkg
91+
if-no-files-found: error
92+
5193
- name: Publish NuGet
5294
if: github.ref == 'refs/heads/master' && matrix.configuration == 'release'
5395
run: |

ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
namespace ICSharpCode.AvalonEdit.Editing
2525
{
2626
[TestFixture]
27+
[Apartment(System.Threading.ApartmentState.STA)]
2728
public class ChangeDocumentTests
2829
{
2930
[Test]

ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
3030
<PackageReference Include="NUnit" Version="3.13.2" />
3131
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
32+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
3233
</ItemGroup>
3334
<ItemGroup>
3435
<ProjectReference Include="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj" />

ICSharpCode.AvalonEdit.Tests/WeakReferenceTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
namespace ICSharpCode.AvalonEdit
2828
{
2929
[TestFixture]
30+
[Apartment(System.Threading.ApartmentState.STA)]
3031
public class WeakReferenceTests
3132
{
3233
[Test]

0 commit comments

Comments
 (0)