Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
OsirisTerje committed Apr 7, 2024
1 parent 369a582 commit b103d4e
Showing 1 changed file with 33 additions and 133 deletions.
166 changes: 33 additions & 133 deletions src/NUnit.TestAdapter.Tests.Acceptance/SinglePassingTestResultTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;

using NUnit.Framework;
using NUnit.Framework;
using NUnit.VisualStudio.TestAdapter.Tests.Acceptance.WorkspaceTools;

namespace NUnit.VisualStudio.TestAdapter.Tests.Acceptance
Expand Down Expand Up @@ -43,12 +40,9 @@ End Class
End Namespace");
}

[TestCaseSource(typeof(SingleFrameworkSource), nameof(SingleFrameworkSource.AllFrameworks))]
[Platform("Win")]
public void Single_target_csproj(SingleFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.csproj", $@"
private IsolatedWorkspace CreateSingleTargetWorkspace(string fileName, SingleFrameworkSource source) =>
CreateWorkspace()
.AddProject(fileName, $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
Expand All @@ -63,10 +57,14 @@ public void Single_target_csproj(SingleFrameworkSource source)
</Project>");

AddTestsCs(workspace);

[TestCaseSource(typeof(SingleFrameworkSource), nameof(SingleFrameworkSource.AllFrameworks))]
[Platform("Win")]
public void Single_target_csproj(SingleFrameworkSource source)
{
var workspace = CreateSingleTargetWorkspace("Test.csproj", source);
AddTestsCs(workspace);
workspace.MsBuild(restore: true);

workspace.VSTest($@"bin\Debug\{source.Framework}\Test.dll", VsTestFilter.NoFilter)
.AssertSinglePassingTest();
}
Expand All @@ -75,51 +73,18 @@ public void Single_target_csproj(SingleFrameworkSource source)
[Platform("Win")]
public void Single_target_csproj_dotnet_CLI(SingleFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.csproj", $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFramework>{source.Framework}</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{source.NUnitVersion}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
</Project>");

var workspace = CreateSingleTargetWorkspace("Test.csproj", source);
AddTestsCs(workspace);

workspace.DotNetTest().AssertSinglePassingTest();
}

[TestCaseSource(typeof(SingleFrameworkSource), nameof(SingleFrameworkSource.AllFrameworks))]
[Platform("Win")]
public void Single_target_vbproj(SingleFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.vbproj", $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFramework>{source.Framework}</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{source.NUnitVersion}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
</Project>");

var workspace = CreateSingleTargetWorkspace("Test.vbproj", source);
AddTestsVb(workspace);

workspace.MsBuild(restore: true);

workspace.VSTest($@"bin\Debug\{source.Framework}\Test.dll", VsTestFilter.NoFilter)
.AssertSinglePassingTest();
}
Expand All @@ -128,49 +93,34 @@ public void Single_target_vbproj(SingleFrameworkSource source)
[Platform("Win")]
public void Single_target_vbproj_dotnet_CLI(SingleFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.vbproj", $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFramework>{source.Framework}</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{source.NUnitVersion}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
</Project>");

var workspace = CreateSingleTargetWorkspace("Test.vbproj", source);
AddTestsVb(workspace);

workspace.DotNetTest().AssertSinglePassingTest();
}

[TestCaseSource(typeof(MultiFrameworkSource), nameof(MultiFrameworkSource.AllFrameworks))]
[Platform("Win")]
public void Multi_target_csproj(MultiFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.csproj", $@"
private IsolatedWorkspace CreateMultiTargetWorkspace(string fileName, MultiFrameworkSource source) =>
CreateWorkspace()
.AddProject(fileName, $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFrameworks>{string.Join(";", source.Frameworks)}</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>{string.Join(";", source.Frameworks)}</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{source.NUnitVersion}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{source.NUnitVersion}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
</Project>");
</Project>");

[TestCaseSource(typeof(MultiFrameworkSource), nameof(MultiFrameworkSource.AllFrameworks))]
[Platform("Win")]
public void Multi_target_csproj(MultiFrameworkSource source)
{
var workspace = CreateMultiTargetWorkspace("Test.csproj", source);
AddTestsCs(workspace);

workspace.MsBuild(restore: true);

foreach (var targetFramework in source.Frameworks)
Expand All @@ -183,49 +133,17 @@ public void Multi_target_csproj(MultiFrameworkSource source)
[TestCaseSource(typeof(MultiFrameworkSource), nameof(MultiFrameworkSource.AllFrameworks))]
public void Multi_target_csproj_dotnet_CLI(MultiFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.csproj", $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFrameworks>{string.Join(";", source.Frameworks)}</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{source.NUnitVersion}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
</Project>");

var workspace = CreateMultiTargetWorkspace("Test.csproj", source);
AddTestsCs(workspace);

workspace.DotNetTest().AssertSinglePassingTest();
}

[TestCaseSource(typeof(MultiFrameworkSource), nameof(MultiFrameworkSource.AllFrameworks))]
[Platform("Win")]
public void Multi_target_vbproj(MultiFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.vbproj", $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFrameworks>{string.Join(";", source.Frameworks)}</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{source.NUnitVersion}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
</Project>");

var workspace = CreateMultiTargetWorkspace("Test.vbproj", source);
AddTestsVb(workspace);

workspace.MsBuild(restore: true);

foreach (var targetFramework in source.Frameworks)
Expand All @@ -238,24 +156,8 @@ public void Multi_target_vbproj(MultiFrameworkSource source)
[TestCaseSource(typeof(MultiFrameworkSource), nameof(MultiFrameworkSource.AllFrameworks))]
public void Multi_target_vbproj_dotnet_CLI(MultiFrameworkSource source)
{
var workspace = CreateWorkspace()
.AddProject("Test.vbproj", $@"
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFrameworks>{string.Join(";", source.Frameworks)}</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='{NUnit3}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
</Project>");

var workspace = CreateMultiTargetWorkspace("Test.vbproj", source);
AddTestsVb(workspace);

workspace.DotNetTest().AssertSinglePassingTest();
}

Expand Down Expand Up @@ -631,9 +533,7 @@ public void Legacy_vbproj_with_packages_config()
AddTestsVb(workspace);

workspace.NuGetRestore(packagesDirectory: "packages");

workspace.MsBuild();

workspace.VSTest(@"bin\Debug\Test.dll", VsTestFilter.NoFilter)
.AssertSinglePassingTest();
}
Expand Down

0 comments on commit b103d4e

Please sign in to comment.