Skip to content

Commit 4fce0ce

Browse files
committed
Update SDK tests
* Add some test for MVC 3.1 \ Blazor 3.1 * Remove tests and testapps for 1.1 \ 2.2
1 parent e204911 commit 4fce0ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+363
-1317
lines changed

src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest11.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest21.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22NetFx.cs

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.IO;
5+
using System.Threading.Tasks;
6+
using Xunit;
7+
8+
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
9+
{
10+
public class BuildWithComponents31IntegrationTest : MSBuildIntegrationTestBase, IClassFixture<BuildServerTestFixture>
11+
{
12+
public BuildWithComponents31IntegrationTest(BuildServerTestFixture buildServer)
13+
: base(buildServer)
14+
{
15+
}
16+
17+
[Fact]
18+
[InitializeTestProject("blazor31")]
19+
public async Task Build_Components_WithDotNetCoreMSBuild_Works()
20+
{
21+
TargetFramework = "netcoreapp3.1";
22+
var result = await DotnetMSBuild("Build");
23+
24+
Assert.BuildPassed(result);
25+
Assert.FileExists(result, OutputPath, "blazor31.dll");
26+
Assert.FileExists(result, OutputPath, "blazor31.pdb");
27+
Assert.FileExists(result, OutputPath, "blazor31.Views.dll");
28+
Assert.FileExists(result, OutputPath, "blazor31.Views.pdb");
29+
30+
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "blazor31.dll"), "blazor31.Pages.Index");
31+
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "blazor31.dll"), "blazor31.Shared.NavMenu");
32+
33+
// Verify a regular View appears in the views dll, but not in the main assembly.
34+
Assert.AssemblyDoesNotContainType(result, Path.Combine(OutputPath, "blazor31.dll"), "blazor31.Pages.Pages__Host");
35+
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "blazor31.Views.dll"), "blazor31.Pages.Pages__Host");
36+
}
37+
}
38+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.IO;
5+
using System.Threading.Tasks;
6+
using Xunit;
7+
8+
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
9+
{
10+
public class MvcBuildIntegrationTest21 : MvcBuildIntegrationTestLegacy
11+
{
12+
public MvcBuildIntegrationTest21(LegacyBuildServerTestFixture buildServer)
13+
: base(buildServer)
14+
{
15+
}
16+
17+
public override string TestProjectName => "SimpleMvc21";
18+
public override string TargetFramework => "netcoreapp2.1";
19+
20+
[Fact]
21+
public async Task Building_WorksWhenMultipleRazorConfigurationsArePresent()
22+
{
23+
using (var project = CreateTestProject())
24+
{
25+
AddProjectFileContent(@"
26+
<ItemGroup>
27+
<RazorConfiguration Include=""MVC-2.1"">
28+
<Extensions>MVC-2.1;$(CustomRazorExtension)</Extensions>
29+
</RazorConfiguration>
30+
</ItemGroup>");
31+
32+
// Build
33+
var result = await DotnetMSBuild("Build");
34+
35+
Assert.BuildPassed(result);
36+
Assert.FileExists(result, OutputPath, "SimpleMvc21.dll");
37+
Assert.FileExists(result, OutputPath, "SimpleMvc21.pdb");
38+
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.dll");
39+
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
40+
}
41+
}
42+
43+
[Fact]
44+
public virtual async Task Build_DoesNotAddRelatedAssemblyPart_IfToolSetIsNotRazorSdk()
45+
{
46+
using (CreateTestProject())
47+
{
48+
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, $"{TestProjectName}.RazorAssemblyInfo.cs");
49+
var result = await DotnetMSBuild("Build", "/p:RazorCompileToolSet=MvcPrecompilation");
50+
51+
Assert.BuildPassed(result);
52+
53+
Assert.FileDoesNotExist(result, razorAssemblyInfo);
54+
Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.RazorTargetAssemblyInfo.cs");
55+
}
56+
}
57+
58+
[Fact]
59+
public virtual async Task Publish_NoopsWithMvcRazorCompileOnPublish_False()
60+
{
61+
using (CreateTestProject())
62+
{
63+
var result = await DotnetMSBuild("Publish", "/p:MvcRazorCompileOnPublish=false");
64+
65+
Assert.BuildPassed(result);
66+
67+
// Everything we do should noop - including building the app.
68+
Assert.FileExists(result, PublishOutputPath, OutputFileName);
69+
Assert.FileExists(result, PublishOutputPath, $"{TestProjectName}.pdb");
70+
Assert.FileDoesNotExist(result, PublishOutputPath, $"{TestProjectName}.Views.dll");
71+
Assert.FileDoesNotExist(result, PublishOutputPath, $"{TestProjectName}.Views.pdb");
72+
}
73+
}
74+
75+
[Fact] // This will use the old precompilation tool, RazorSDK shouldn't get involved.
76+
public virtual async Task Build_WithMvcRazorCompileOnPublish_Noops()
77+
{
78+
using (CreateTestProject())
79+
{
80+
var result = await DotnetMSBuild("Build", "/p:MvcRazorCompileOnPublish=true");
81+
82+
Assert.BuildPassed(result);
83+
84+
Assert.FileExists(result, IntermediateOutputPath, OutputFileName);
85+
Assert.FileExists(result, IntermediateOutputPath, OutputFileName);
86+
Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.Views.dll");
87+
Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.Views.pdb");
88+
}
89+
}
90+
}
91+
}

src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest22.cs renamed to src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/MvcBuildIntegrationTest31.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
55
{
6-
public class BuildIntegrationTest22 : BuildIntegrationTestLegacy
6+
public class MvcBuildIntegrationTest31 : MvcBuildIntegrationTestLegacy
77
{
8-
public BuildIntegrationTest22(LegacyBuildServerTestFixture buildServer)
8+
public MvcBuildIntegrationTest31(LegacyBuildServerTestFixture buildServer)
99
: base(buildServer)
1010
{
1111
}
1212

13-
public override string TestProjectName => "SimpleMvc22";
14-
public override string TargetFramework => "netcoreapp2.2";
13+
public override string TestProjectName => "SimpleMvc31";
14+
public override string TargetFramework => "netcoreapp3.1";
1515
}
1616
}

0 commit comments

Comments
 (0)