Merge remote-tracking branch 'MvcPrecompilation/rybrande/masterToSrc' into rybrande/MondoMaster

This commit is contained in:
Ryan Brandenburg 2018-11-27 15:47:49 -08:00
commit b541eca8d9
52 changed files with 1641 additions and 35 deletions

View File

@ -3,31 +3,31 @@
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-20180928.5</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreMvcRazorPagesPackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreMvcRazorPagesPackageVersion>
<MicrosoftAspNetCoreRazorDesignPackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreRazorDesignPackageVersion>
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreRazorRuntimePackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.6.0-preview3-35359</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>2.2.0-preview3-35359</MicrosoftAspNetCoreTestingPackageVersion>
<InternalAspNetCoreSdkPackageVersion>3.0.0-alpha1-20180821.3</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreMvcRazorPagesPackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreMvcRazorPagesPackageVersion>
<MicrosoftAspNetCoreRazorDesignPackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreRazorDesignPackageVersion>
<MicrosoftAspNetCoreRazorRuntimePackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreRazorRuntimePackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.7.0-alpha1-10352</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>3.0.0-alpha1-10352</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftBuildTasksCorePackageVersion>15.6.82</MicrosoftBuildTasksCorePackageVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.2.0-preview3-35359</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.2.0-preview3-35359</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.2.0-preview3-35359</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.2.0-preview3-35359</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.2.0-preview3-35359</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>3.0.0-alpha1-10352</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>3.0.0-alpha1-10352</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>3.0.0-alpha1-10352</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>3.0.0-alpha1-10352</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>3.0.0-alpha1-10352</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftNETCoreApp20PackageVersion>2.0.9</MicrosoftNETCoreApp20PackageVersion>
<MicrosoftNETCoreApp21PackageVersion>2.1.3</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNETCoreApp22PackageVersion>2.2.0-preview3-26927-02</MicrosoftNETCoreApp22PackageVersion>
<MicrosoftNETSdkRazorPackageVersion>2.2.0-preview3-35359</MicrosoftNETSdkRazorPackageVersion>
<MicrosoftNETCoreApp21PackageVersion>2.1.2</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNETCoreApp22PackageVersion>2.2.0-preview1-26618-02</MicrosoftNETCoreApp22PackageVersion>
<MicrosoftNETSdkRazorPackageVersion>3.0.0-alpha1-10352</MicrosoftNETSdkRazorPackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
<XunitPackageVersion>2.3.1</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.4.0</XunitRunnerVisualStudioPackageVersion>
</PropertyGroup>
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
<PropertyGroup Label="Package Versions: Pinned" />
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
</Project>

View File

@ -4,7 +4,6 @@
<PropertyGroup>
<!-- These properties are use by the automation that updates dependencies.props -->
<LineupPackageId>Internal.AspNetCore.Universe.Lineup</LineupPackageId>
<LineupPackageVersion>2.2.0-*</LineupPackageVersion>
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json</LineupPackageRestoreSource>
</PropertyGroup>

View File

@ -0,0 +1,62 @@
// 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.Threading.Tasks;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class ApplicationWithConfigureMvcTest_CoreCLR
: LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<ApplicationWithConfigureStartup.Startup>>
{
public ApplicationWithConfigureMvcTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithConfigureStartup.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task Precompilation_RunsConfiguredCompilationCallbacks()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
}
}
[Fact]
public async Task Precompilation_UsesConfiguredParseOptions()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/ViewWithPreprocessor",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent(
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
response);
}
}
}
}

View File

@ -0,0 +1,105 @@
// 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;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class ApplicationWithCustomInputFilesTest_CoreCLR
: LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<ApplicationWithCustomInputFiles.Startup>>
{
public ApplicationWithCustomInputFilesTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithCustomInputFiles.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task ApplicationWithCustomInputFiles_Works()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var expectedText = "Hello Index!";
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
Assert.Equal(expectedText, response.Trim());
}
}
[Fact]
public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var expectedViews = new[]
{
"/Views/Home/About.cshtml",
"/Views/Home/Index.cshtml",
};
// Act
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/GetPrecompiledResourceNames",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
Assert.Equal(expectedViews, actual);
}
}
[Fact]
public async Task MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var viewsNotPublished = new[]
{
"Index.cshtml",
"About.cshtml",
};
var viewsPublished = new[]
{
"NotIncluded.cshtml",
};
var viewsDirectory = Path.Combine(deployment.ContentRoot, "Views", "Home");
// Act & Assert
foreach (var file in viewsPublished)
{
var filePath = Path.Combine(viewsDirectory, file);
Assert.True(File.Exists(filePath), $"{filePath} was not published.");
}
foreach (var file in viewsNotPublished)
{
var filePath = Path.Combine(viewsDirectory, file);
Assert.False(File.Exists(filePath), $"{filePath} was published.");
}
}
}
}
}

View File

@ -0,0 +1,49 @@
// 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;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
namespace FunctionalTests
{
public class ApplicationWithParseErrorsTest_CoreCLR
: IClassFixture<CoreCLRApplicationTestFixture<ApplicationWithParseErrors.Startup>>
{
public ApplicationWithParseErrorsTest_CoreCLR(CoreCLRApplicationTestFixture<ApplicationWithParseErrors.Startup> fixture)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact(Skip = "Flaky test in many build configurations. See issue #277.")]
public async Task PublishingPrintsParseErrors()
{
// Arrange
var indexPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "Index.cshtml");
var viewImportsPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "About.cshtml");
var expectedErrors = new[]
{
indexPath + " (0): The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" character for all the \"{\" characters within this block, and that none of the \"}\" characters are being interpreted as markup.",
viewImportsPath + " (1): A space or line break was encountered after the \"@\" character. Only valid identifiers, keywords, comments, \"(\" and \"{\" are valid at the start of a code block and they must occur immediately following \"@\" with no space in between.",
};
var testSink = new TestSink();
var loggerFactory = new TestLoggerFactory(testSink, enabled: true);
// Act
await Assert.ThrowsAsync<Exception>(() => Fixture.CreateDeploymentAsync(loggerFactory));
// Assert
var logs = testSink.Writes.Select(w => w.State.ToString().Trim()).ToList();
foreach (var expectedError in expectedErrors)
{
Assert.Contains(logs, log => log.Contains(expectedError));
}
}
}
}

View File

@ -0,0 +1,75 @@
// 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 Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class ApplicationWithTagHelpersTest_CoreCLR :
LoggedTest, IClassFixture<ApplicationWithTagHelpersTest_CoreCLR.ApplicationWithTagHelpersTestFixture>
{
public ApplicationWithTagHelpersTest_CoreCLR(
ApplicationWithTagHelpersTestFixture fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task Precompilation_WorksForViewsThatUseTagHelpersFromProjectReferences()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/ClassLibraryTagHelper",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.ClassLibraryTagHelper.txt", response);
}
}
[Fact]
public async Task Precompilation_WorksForViewsThatUseTagHelpersFromCurrentProject()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/LocalTagHelper",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.LocalTagHelper.txt", response);
}
}
public class ApplicationWithTagHelpersTestFixture : CoreCLRApplicationTestFixture<ApplicationWithTagHelpers.Startup>
{
protected override Task<DeploymentResult> CreateDeploymentAsyncCore(ILoggerFactory loggerFactory)
{
CopyDirectory(
new DirectoryInfo(Path.Combine(ApplicationPath, "..", "ClassLibraryTagHelper")),
new DirectoryInfo(Path.Combine(WorkingDirectory, "ClassLibraryTagHelper")));
return base.CreateDeploymentAsyncCore(loggerFactory);
}
}
}
}

View File

@ -0,0 +1,62 @@
// 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;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class PublishWithEmbedViewSourcesTest_CoreCLR
: LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<PublishWithEmbedViewSources.Startup>>
{
public PublishWithEmbedViewSourcesTest_CoreCLR(
CoreCLRApplicationTestFixture<PublishWithEmbedViewSources.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task Precompilation_CanEmbedViewSourcesAsResources()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var logger = loggerFactory.CreateLogger(Fixture.ApplicationName);
var expectedViews = new[]
{
"/Areas/TestArea/Views/Home/Index.cshtml",
"/Views/Home/About.cshtml",
"/Views/Home/Index.cshtml",
};
var expectedText = "Hello Index!";
// Act - 1
var response1 = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/Index",
logger);
// Assert - 1
Assert.Equal(expectedText, response1.Trim());
// Act - 2
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/GetPrecompiledResourceNames",
logger);
// Assert - 2
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
Assert.Equal(expectedViews, actual);
}
}
}
}

View File

@ -0,0 +1,134 @@
// 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.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class RazorPagesAppTest_CoreCLR :
LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<RazorPagesApp.Startup>>
{
public RazorPagesAppTest_CoreCLR(
CoreCLRApplicationTestFixture<RazorPagesApp.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")]
public async Task Precompilation_WorksForIndexPage_UsingFolderName()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
}
}
[Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")]
public async Task Precompilation_WorksForIndexPage_UsingFileName()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/Index",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
}
}
[Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")]
public async Task Precompilation_WorksForPageWithModel()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/PageWithModel?person=Dan",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response);
}
}
[Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")]
public async Task Precompilation_WorksForPageWithRoute()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/PageWithRoute/Dan",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response);
}
}
[Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")]
public async Task Precompilation_WorksForPageInNestedFolder()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/Nested1/Nested2/PageWithTagHelper",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response);
}
}
[Fact(Skip = "https://github.com/aspnet/MvcPrecompilation/issues/287")]
public async Task Precompilation_WorksWithPageConventions()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await RetryHelper.RetryRequest(
() => deployment.HttpClient.GetAsync("/Auth/Index"),
loggerFactory.CreateLogger(Fixture.ApplicationName),
retryCount: 5);
// Assert
Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery);
}
}
}
}

View File

@ -0,0 +1,46 @@
// 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 Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
// Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1
public class RazorSdkNeitherUsedTest_CoreCLR : LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<ApplicationWithRazorSdkNeitherUsed.Startup>>
{
public RazorSdkNeitherUsedTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithRazorSdkNeitherUsed.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task Publish_HasNoPrecompilation()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await RetryHelper.RetryRequest(
() => deployment.HttpClient.GetAsync(deployment.ApplicationBaseUri),
loggerFactory.CreateLogger(Fixture.ApplicationName),
retryCount: 5);
// Assert
Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkNeitherUsed.PrecompiledViews.dll")));
Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkNeitherUsed.Views.dll")));
}
}
}
}

View File

@ -0,0 +1,45 @@
// 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 Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
// Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1
public class RazorSdkPrecompilationUsedTest_CoreCLR : LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<ApplicationWithRazorSdkPrecompilationUsed.Startup>>
{
public RazorSdkPrecompilationUsedTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithRazorSdkPrecompilationUsed.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task Publish_UsesRazorSDK()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
Assert.True(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkPrecompilationUsed.PrecompiledViews.dll")));
Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkPrecompilationUsed.Views.dll")));
TestEmbeddedResource.AssertContent("ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt", response);
}
}
}
}

View File

@ -0,0 +1,47 @@
// 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 Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
// Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1
public class RazorSdkUsedTest_CoreCLR : LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<ApplicationWithRazorSdkUsed.Startup>>
{
public RazorSdkUsedTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithRazorSdkUsed.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task Publish_UsesRazorSDK()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var expectedViewLocation = Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkUsed.Views.dll");
var expectedPrecompiledViewsLocation = Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkUsed.PrecompiledViews.dll");
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
Assert.False(File.Exists(expectedPrecompiledViewsLocation), $"{expectedPrecompiledViewsLocation} existed, but shouldn't have.");
Assert.True(File.Exists(expectedViewLocation), $"{expectedViewLocation} didn't exist.");
TestEmbeddedResource.AssertContent("ApplicationWithRazorSdkUsed.Home.Index.txt", response);
}
}
}
}

View File

@ -0,0 +1,52 @@
// 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.Threading.Tasks;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class SimpleAppWithAssemblyRenameTest_CoreCLR :
LoggedTest, IClassFixture<SimpleAppWithAssemblyRenameTest_CoreCLR.TestFixture>
{
public SimpleAppWithAssemblyRenameTest_CoreCLR(
TestFixture fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task Precompilation_WorksForSimpleApps()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
}
}
public class TestFixture : CoreCLRApplicationTestFixture<SimpleAppWithAssemblyRename.Startup>
{
public TestFixture()
: base(
typeof(SimpleAppWithAssemblyRename.Startup).Assembly.GetName().Name,
ApplicationPaths.GetTestAppDirectory(nameof(SimpleAppWithAssemblyRename)))
{
}
}
}
}

View File

@ -0,0 +1,42 @@
// 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.Threading.Tasks;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class StrongNamedAppTest_CoreCLR :
LoggedTest, IClassFixture<CoreCLRApplicationTestFixture<StrongNamedApp.Startup>>
{
public StrongNamedAppTest_CoreCLR(
CoreCLRApplicationTestFixture<StrongNamedApp.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task PrecompiledAssembliesUseSameStrongNameAsApplication()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response);
}
}
}
}

View File

@ -0,0 +1,57 @@
// 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.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
public class ViewCompilationOptions_CoreCLR_ScenarioRefAssembliesDoNotGetPublished :
LoggedTest, IClassFixture<ViewCompilationOptions_CoreCLR_ScenarioRefAssembliesDoNotGetPublished.TestFixture>
{
public ViewCompilationOptions_CoreCLR_ScenarioRefAssembliesDoNotGetPublished(
TestFixture fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[Fact]
public async Task PublishingWithOption_AllowsPublishingRefAssemblies()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act & Assert
Assert.True(Directory.Exists(Path.Combine(deployment.ContentRoot, "refs")));
}
}
public class TestFixture : CoreCLRApplicationTestFixture<SimpleApp.Startup>
{
public TestFixture()
{
PublishOnly = true;
}
protected override DeploymentParameters GetDeploymentParameters()
{
var deploymentParameters = base.GetDeploymentParameters();
deploymentParameters.PublishEnvironmentVariables.Add(
new KeyValuePair<string, string>("MvcRazorExcludeRefAssembliesFromPublish", "false"));
return deploymentParameters;
}
}
}
}

View File

@ -0,0 +1,65 @@
// 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.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class ApplicationWithConfigureMvcTest_Desktop
: LoggedTest, IClassFixture<DesktopApplicationTestFixture<ApplicationWithConfigureStartup.Startup>>
{
public ApplicationWithConfigureMvcTest_Desktop(
DesktopApplicationTestFixture<ApplicationWithConfigureStartup.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task Precompilation_RunsConfiguredCompilationCallbacks()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
}
}
[ConditionalFact]
public async Task Precompilation_UsesConfiguredParseOptions()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/ViewWithPreprocessor",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent(
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
response);
}
}
}
}

View File

@ -0,0 +1,108 @@
// 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;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class ApplicationWithCustomInputFilesTest_Desktop
: LoggedTest, IClassFixture<DesktopApplicationTestFixture<ApplicationWithCustomInputFiles.Startup>>
{
public ApplicationWithCustomInputFilesTest_Desktop(
DesktopApplicationTestFixture<ApplicationWithCustomInputFiles.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task ApplicationWithCustomInputFiles_Works()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var expectedText = "Hello Index!";
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
Assert.Equal(expectedText, response.Trim());
}
}
[ConditionalFact]
public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var expectedViews = new[]
{
"/Views/Home/About.cshtml",
"/Views/Home/Index.cshtml",
};
// Act
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/GetPrecompiledResourceNames",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
Assert.Equal(expectedViews, actual);
}
}
[ConditionalFact]
public async Task MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var viewsNotPublished = new[]
{
"Index.cshtml",
"About.cshtml",
};
var viewsPublished = new[]
{
"NotIncluded.cshtml",
};
var viewsDirectory = Path.Combine(deployment.ContentRoot, "Views", "Home");
// Act & Assert
foreach (var file in viewsPublished)
{
var filePath = Path.Combine(viewsDirectory, file);
Assert.True(File.Exists(filePath), $"{filePath} was not published.");
}
foreach (var file in viewsNotPublished)
{
var filePath = Path.Combine(viewsDirectory, file);
Assert.False(File.Exists(filePath), $"{filePath} was published.");
}
}
}
}
}

View File

@ -0,0 +1,52 @@
// 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;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class ApplicationWithParseErrorsTest_Desktop
: IClassFixture<DesktopApplicationTestFixture<ApplicationWithParseErrors.Startup>>
{
public ApplicationWithParseErrorsTest_Desktop(DesktopApplicationTestFixture<ApplicationWithParseErrors.Startup> fixture)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact(Skip = "Flaky test in many build configurations.See issue #277.")]
public async Task PublishingPrintsParseErrors()
{
// Arrange
var indexPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "Index.cshtml");
var viewImportsPath = Path.Combine(Fixture.TestProjectDirectory, "Views", "Home", "About.cshtml");
var expectedErrors = new[]
{
indexPath + " (0): The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" character for all the \"{\" characters within this block, and that none of the \"}\" characters are being interpreted as markup.",
viewImportsPath + " (1): A space or line break was encountered after the \"@\" character. Only valid identifiers, keywords, comments, \"(\" and \"{\" are valid at the start of a code block and they must occur immediately following \"@\" with no space in between.",
};
var testSink = new TestSink();
var loggerFactory = new TestLoggerFactory(testSink, enabled: true);
// Act
await Assert.ThrowsAsync<Exception>(() => Fixture.CreateDeploymentAsync(loggerFactory));
// Assert
var logs = testSink.Writes.Select(w => w.State.ToString().Trim()).ToList();
foreach (var expectedError in expectedErrors)
{
Assert.Contains(logs, log => log.Contains(expectedError));
}
}
}
}

View File

@ -0,0 +1,78 @@
// 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 Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class ApplicationWithTagHelpersTest_Desktop :
LoggedTest, IClassFixture<ApplicationWithTagHelpersTest_Desktop.ApplicationWithTagHelpersTestFixture>
{
public ApplicationWithTagHelpersTest_Desktop(
ApplicationWithTagHelpersTestFixture fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task Precompilation_WorksForViewsThatUseTagHelpersFromProjectReferences()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/ClassLibraryTagHelper",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.ClassLibraryTagHelper.txt", response);
}
}
[ConditionalFact]
public async Task Precompilation_WorksForViewsThatUseTagHelpersFromCurrentProject()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/LocalTagHelper",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.LocalTagHelper.txt", response);
}
}
public class ApplicationWithTagHelpersTestFixture : DesktopApplicationTestFixture<ApplicationWithTagHelpers.Startup>
{
protected override Task<DeploymentResult> CreateDeploymentAsyncCore(ILoggerFactory loggerFactory)
{
CopyDirectory(
new DirectoryInfo(Path.Combine(ApplicationPath, "..", "ClassLibraryTagHelper")),
new DirectoryInfo(Path.Combine(WorkingDirectory, "ClassLibraryTagHelper")));
return base.CreateDeploymentAsyncCore(loggerFactory);
}
}
}
}

View File

@ -0,0 +1,65 @@
// 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;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class PublishWithEmbedViewSourcesTest_Desktop
: LoggedTest, IClassFixture<DesktopApplicationTestFixture<PublishWithEmbedViewSources.Startup>>
{
public PublishWithEmbedViewSourcesTest_Desktop(
DesktopApplicationTestFixture<PublishWithEmbedViewSources.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task Precompilation_CanEmbedViewSourcesAsResources()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
var logger = loggerFactory.CreateLogger(Fixture.ApplicationName);
var expectedViews = new[]
{
"/Areas/TestArea/Views/Home/Index.cshtml",
"/Views/Home/About.cshtml",
"/Views/Home/Index.cshtml",
};
var expectedText = "Hello Index!";
// Act - 1
var response1 = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/Index",
logger);
// Assert - 1
Assert.Equal(expectedText, response1.Trim());
// Act - 2
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
"Home/GetPrecompiledResourceNames",
logger);
// Assert - 2
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
Assert.Equal(expectedViews, actual);
}
}
}
}

View File

@ -0,0 +1,137 @@
// 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.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class RazorPagesAppTest_Desktop :
LoggedTest, IClassFixture<DesktopApplicationTestFixture<RazorPagesApp.Startup>>
{
public RazorPagesAppTest_Desktop(
DesktopApplicationTestFixture<RazorPagesApp.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task Precompilation_WorksForIndexPage_UsingFolderName()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
}
}
[ConditionalFact]
public async Task Precompilation_WorksForIndexPage_UsingFileName()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/Index",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
}
}
[ConditionalFact]
public async Task Precompilation_WorksForPageWithModel()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/PageWithModel?person=Dan",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response);
}
}
[ConditionalFact]
public async Task Precompilation_WorksForPageWithRoute()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/PageWithRoute/Dan",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response);
}
}
[ConditionalFact]
public async Task Precompilation_WorksForPageInNestedFolder()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
"/Nested1/Nested2/PageWithTagHelper",
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response);
}
}
[ConditionalFact]
public async Task Precompilation_WorksWithPageConventions()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await RetryHelper.RetryRequest(
() => deployment.HttpClient.GetAsync("/Auth/Index"),
loggerFactory.CreateLogger(Fixture.ApplicationName),
retryCount: 5);
// Assert
Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery);
}
}
}
}

View File

@ -0,0 +1,57 @@
// 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.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class SimpleAppTestWithPlatformx86_Desktop :
LoggedTest, IClassFixture<DesktopApplicationTestFixture<SimpleApp.Startup>>
{
public SimpleAppTestWithPlatformx86_Desktop(
DesktopApplicationTestFixture<SimpleApp.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task Precompilation_PublishingForPlatform()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
}
}
public class SimpleAppTestWithPlatformx86_DesktopFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
{
protected override DeploymentParameters GetDeploymentParameters()
{
var parameters = base.GetDeploymentParameters();
parameters.AdditionalPublishParameters = "/p:Platform=x86";
return parameters;
}
}
}
}

View File

@ -0,0 +1,55 @@
// 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.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class SimpleAppWithAssemblyRenameTest_Desktop :
LoggedTest, IClassFixture<SimpleAppWithAssemblyRenameTest_Desktop.TestFixture>
{
public SimpleAppWithAssemblyRenameTest_Desktop(
TestFixture fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task Precompilation_WorksForSimpleApps()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
}
}
public class TestFixture : DesktopApplicationTestFixture<SimpleAppWithAssemblyRename.Startup>
{
public TestFixture()
: base(
typeof(SimpleAppWithAssemblyRename.Startup).Assembly.GetName().Name,
ApplicationPaths.GetTestAppDirectory(nameof(SimpleAppWithAssemblyRename)))
{
}
}
}
}

View File

@ -0,0 +1,45 @@
// 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.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class StrongNamedAppTest_Desktop :
LoggedTest, IClassFixture<DesktopApplicationTestFixture<StrongNamedApp.Startup>>
{
public StrongNamedAppTest_Desktop(
DesktopApplicationTestFixture<StrongNamedApp.Startup> fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task PrecompiledAssembliesUseSameStrongNameAsApplication()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act
var response = await deployment.HttpClient.GetStringWithRetryAsync(
deployment.ApplicationBaseUri,
loggerFactory.CreateLogger(Fixture.ApplicationName));
// Assert
TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response);
}
}
}
}

View File

@ -0,0 +1,60 @@
// 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.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace FunctionalTests
{
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class ViewCompilationOptions_Desktop_ScenarioRefAssembliesDoNotGetPublished :
LoggedTest, IClassFixture<ViewCompilationOptions_Desktop_ScenarioRefAssembliesDoNotGetPublished.TestFixture>
{
public ViewCompilationOptions_Desktop_ScenarioRefAssembliesDoNotGetPublished(
TestFixture fixture,
ITestOutputHelper output)
: base(output)
{
Fixture = fixture;
}
public ApplicationTestFixture Fixture { get; }
[ConditionalFact]
public async Task PublishingWithOption_AllowsPublishingRefAssemblies()
{
using (StartLog(out var loggerFactory))
{
// Arrange
var deployment = await Fixture.CreateDeploymentAsync(loggerFactory);
// Act & Assert
Assert.True(Directory.Exists(Path.Combine(deployment.ContentRoot, "refs")));
}
}
public class TestFixture : DesktopApplicationTestFixture<SimpleApp.Startup>
{
public TestFixture()
{
PublishOnly = true;
}
protected override DeploymentParameters GetDeploymentParameters()
{
var deploymentParameters = base.GetDeploymentParameters();
deploymentParameters.PublishEnvironmentVariables.Add(
new KeyValuePair<string, string>("MvcRazorExcludeRefAssembliesFromPublish", "false"));
return deploymentParameters;
}
}
}
}

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<body>
ClassLibraryWithPrecompiledViews.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
<h1>Admin home page</h1>
Test section
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
ApplicationUsingRelativePaths.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Hello from Index!
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
ApplicationUsingRelativePaths.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Hello from Index!
</body>
</html>

View File

@ -0,0 +1,2 @@
ApplicationWithConfigureMvc.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
<br />Hello world!

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
ApplicationWithRazorSdkPrecompilationUsed.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Hello from Index!
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
ApplicationWithRazorSdkUsed.Views, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Hello from Index!
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title> - ApplicationWithTagHelpers</title>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css" />
<meta name="x-stylesheet-fallback-test" content="" class="sr-only" /><script>!function(a,b,c,d){var e,f=document,g=f.getElementsByTagName("SCRIPT"),h=g[g.length-1].previousElementSibling,i=f.defaultView&&f.defaultView.getComputedStyle?f.defaultView.getComputedStyle(h):h.currentStyle;if(i&&i[a]!==b)for(e=0;e<c.length;e++)f.write('<link href="'+c[e]+'" '+d+"/>")}("position","absolute",["\/lib\/bootstrap\/dist\/css\/bootstrap.min.css"], "rel=\u0022stylesheet\u0022 ");</script>
</head>
<body>
<div class="container body-content">
ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
<div><b>To boldy tag that no one has ever tagged before...</b></div>
<hr />
<footer>
<p>&copy; 2016 - ApplicationWithTagHelpers</p>
</footer>
</div>
ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title> - ApplicationWithTagHelpers</title>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css" />
<meta name="x-stylesheet-fallback-test" content="" class="sr-only" /><script>!function(a,b,c,d){var e,f=document,g=f.getElementsByTagName("SCRIPT"),h=g[g.length-1].previousElementSibling,i=f.defaultView&&f.defaultView.getComputedStyle?f.defaultView.getComputedStyle(h):h.currentStyle;if(i&&i[a]!==b)for(e=0;e<c.length;e++)f.write('<link href="'+c[e]+'" '+d+"/>")}("position","absolute",["\/lib\/bootstrap\/dist\/css\/bootstrap.min.css"], "rel=\u0022stylesheet\u0022 ");</script>
</head>
<body>
<div class="container body-content">
ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
<test href="/Home/About">TestTagHelper content.</test>
<hr />
<footer>
<p>&copy; 2016 - ApplicationWithTagHelpers</p>
</footer>
</div>
ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
</body>
</html>

View File

@ -0,0 +1,2 @@
Hello world!

View File

@ -0,0 +1,2 @@
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css" />
<meta name="x-stylesheet-fallback-test" content="" class="sr-only" /><script>!function(a,b,c,d){var e,f=document,g=f.getElementsByTagName("SCRIPT"),h=g[g.length-1].previousElementSibling,i=f.defaultView&&f.defaultView.getComputedStyle?f.defaultView.getComputedStyle(h):h.currentStyle;if(i&&i[a]!==b)for(e=0;e<c.length;e++)f.write('<link href="'+c[e]+'" '+d+"/>")}("position","absolute",["\/lib\/bootstrap\/dist\/css\/bootstrap.min.css"], "rel=\u0022stylesheet\u0022 ");</script>

View File

@ -0,0 +1,2 @@
Greetings Dan!

View File

@ -0,0 +1,2 @@
Greetings Dan!

View File

@ -0,0 +1,2 @@
NewAssemblyName.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

View File

@ -0,0 +1 @@
Hello from view in StrongNamedApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60

View File

@ -9,7 +9,6 @@ namespace ApplicationWithConfigureStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
var builder = services.AddMvc();
ConfigureMvc(builder);
@ -17,6 +16,7 @@ namespace ApplicationWithConfigureStartup
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvc(routes =>
{
routes.MapRoute(

View File

@ -8,13 +8,13 @@ namespace ApplicationWithCustomInputFiles
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvc(routes =>
{
routes.MapRoute(

View File

@ -8,12 +8,12 @@ namespace ApplicationWithParseErrors
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvcWithDefaultRoute();
}
}

View File

@ -8,13 +8,13 @@ namespace ApplicationWithRazorSdkNeitherUsed
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvcWithDefaultRoute();
}
}

View File

@ -8,13 +8,13 @@ namespace ApplicationWithRazorSdkPrecompilationUsed
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvcWithDefaultRoute();
}
}

View File

@ -8,13 +8,13 @@ namespace ApplicationWithRazorSdkUsed
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvcWithDefaultRoute();
}
}

View File

@ -8,13 +8,13 @@ namespace ApplicationWithTagHelpers
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvc(routes =>
{
routes.MapRoute(

View File

@ -8,13 +8,13 @@ namespace PublishWithEmbedViewSources
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvc(routes =>
{
routes.MapRoute(

View File

@ -10,7 +10,6 @@ namespace RazorPagesApp
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
var builder = services.AddMvc();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => options.LoginPath = "/Login");
ConfigureMvc(builder);
@ -18,6 +17,7 @@ namespace RazorPagesApp
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseAuthentication();
app.UseMvc();
}

View File

@ -8,13 +8,13 @@ namespace SimpleApp
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvc(routes =>
{
routes.MapRoute(

View File

@ -8,13 +8,13 @@ namespace SimpleAppWithAssemblyRename
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvcWithDefaultRoute();
}
}

View File

@ -8,13 +8,13 @@ namespace StrongNamedApp
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder => loggingBuilder.AddConsole());
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseMvc(routes =>
{
routes.MapRoute(

View File

@ -1,7 +1,7 @@
<Project>
<Project>
<PropertyGroup>
<VersionPrefix>2.2.0</VersionPrefix>
<VersionSuffix>rtm</VersionSuffix>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionSuffix>alpha1</VersionSuffix>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
<BuildNumber Condition="'$(BuildNumber)' == ''">t000</BuildNumber>