Skip to content

Update SDK tests #22560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.IO;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
{
public class BuildWithComponents31IntegrationTest : MSBuildIntegrationTestBase, IClassFixture<BuildServerTestFixture>
{
public BuildWithComponents31IntegrationTest(BuildServerTestFixture buildServer)
: base(buildServer)
{
}

[Fact]
[InitializeTestProject("blazor31")]
public async Task Build_Components_WithDotNetCoreMSBuild_Works()
{
TargetFramework = "netcoreapp3.1";
var result = await DotnetMSBuild("Build");

Assert.BuildPassed(result);
Assert.FileExists(result, OutputPath, "blazor31.dll");
Assert.FileExists(result, OutputPath, "blazor31.pdb");
Assert.FileExists(result, OutputPath, "blazor31.Views.dll");
Assert.FileExists(result, OutputPath, "blazor31.Views.pdb");

Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "blazor31.dll"), "blazor31.Pages.Index");
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "blazor31.dll"), "blazor31.Shared.NavMenu");

// Verify a regular View appears in the views dll, but not in the main assembly.
Assert.AssemblyDoesNotContainType(result, Path.Combine(OutputPath, "blazor31.dll"), "blazor31.Pages.Pages__Host");
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "blazor31.Views.dll"), "blazor31.Pages.Pages__Host");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.IO;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
{
public class MvcBuildIntegrationTest21 : MvcBuildIntegrationTestLegacy
{
public MvcBuildIntegrationTest21(LegacyBuildServerTestFixture buildServer)
: base(buildServer)
{
}

public override string TestProjectName => "SimpleMvc21";
public override string TargetFramework => "netcoreapp2.1";

[Fact]
public async Task Building_WorksWhenMultipleRazorConfigurationsArePresent()
{
using (var project = CreateTestProject())
{
AddProjectFileContent(@"
<ItemGroup>
<RazorConfiguration Include=""MVC-2.1"">
<Extensions>MVC-2.1;$(CustomRazorExtension)</Extensions>
</RazorConfiguration>
</ItemGroup>");

// Build
var result = await DotnetMSBuild("Build");

Assert.BuildPassed(result);
Assert.FileExists(result, OutputPath, "SimpleMvc21.dll");
Assert.FileExists(result, OutputPath, "SimpleMvc21.pdb");
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.dll");
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
}
}

[Fact]
public virtual async Task Build_DoesNotAddRelatedAssemblyPart_IfToolSetIsNotRazorSdk()
{
using (CreateTestProject())
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, $"{TestProjectName}.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:RazorCompileToolSet=MvcPrecompilation");

Assert.BuildPassed(result);

Assert.FileDoesNotExist(result, razorAssemblyInfo);
Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.RazorTargetAssemblyInfo.cs");
}
}

[Fact]
public virtual async Task Publish_NoopsWithMvcRazorCompileOnPublish_False()
{
using (CreateTestProject())
{
var result = await DotnetMSBuild("Publish", "/p:MvcRazorCompileOnPublish=false");

Assert.BuildPassed(result);

// Everything we do should noop - including building the app.
Assert.FileExists(result, PublishOutputPath, OutputFileName);
Assert.FileExists(result, PublishOutputPath, $"{TestProjectName}.pdb");
Assert.FileDoesNotExist(result, PublishOutputPath, $"{TestProjectName}.Views.dll");
Assert.FileDoesNotExist(result, PublishOutputPath, $"{TestProjectName}.Views.pdb");
}
}

[Fact] // This will use the old precompilation tool, RazorSDK shouldn't get involved.
public virtual async Task Build_WithMvcRazorCompileOnPublish_Noops()
{
using (CreateTestProject())
{
var result = await DotnetMSBuild("Build", "/p:MvcRazorCompileOnPublish=true");

Assert.BuildPassed(result);

Assert.FileExists(result, IntermediateOutputPath, OutputFileName);
Assert.FileExists(result, IntermediateOutputPath, OutputFileName);
Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.Views.dll");
Assert.FileDoesNotExist(result, IntermediateOutputPath, $"{TestProjectName}.Views.pdb");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
{
public class BuildIntegrationTest22 : BuildIntegrationTestLegacy
public class MvcBuildIntegrationTest31 : MvcBuildIntegrationTestLegacy
{
public BuildIntegrationTest22(LegacyBuildServerTestFixture buildServer)
public MvcBuildIntegrationTest31(LegacyBuildServerTestFixture buildServer)
: base(buildServer)
{
}

public override string TestProjectName => "SimpleMvc22";
public override string TargetFramework => "netcoreapp2.2";
public override string TestProjectName => "SimpleMvc31";
public override string TargetFramework => "netcoreapp3.1";
}
}
Loading