Fix functional tests to properly dispose of their app deployer.
This commit is contained in:
parent
4a308f1e9d
commit
2dbe4b79c4
|
|
@ -24,15 +24,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task ConsumingClassLibrariesWithPrecompiledViewsWork(RuntimeFlavor flavor)
|
public async Task ConsumingClassLibrariesWithPrecompiledViewsWork(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
Fixture.CreateDeployment(flavor);
|
{
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger);
|
var response = await deployment.HttpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt", response);
|
TestEmbeddedResource.AssertContent("ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ApplicationConsumingPrecompiledViewsFixture : ApplicationTestFixture
|
public class ApplicationConsumingPrecompiledViewsFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,32 +25,35 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task Precompilation_WorksForViewsUsingRelativePath(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForViewsUsingRelativePath(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.Index.txt", response);
|
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task Precompilation_WorksForViewsUsingDirectoryTraversal(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForViewsUsingDirectoryTraversal(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.About.txt", response);
|
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.About.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ApplicationUsingRelativePathsTestFixture : ApplicationTestFixture
|
public class ApplicationUsingRelativePathsTestFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,26 +25,28 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task Precompilation_RunsConfiguredCompilationCallbacks(RuntimeFlavor flavor)
|
public async Task Precompilation_RunsConfiguredCompilationCallbacks(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
|
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task Precompilation_UsesConfiguredParseOptions(RuntimeFlavor flavor)
|
public async Task Precompilation_UsesConfiguredParseOptions(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"Home/ViewWithPreprocessor",
|
"Home/ViewWithPreprocessor",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
|
|
@ -53,6 +55,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
|
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
|
||||||
response);
|
response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ApplicationWithConfigureMvcFixture : ApplicationTestFixture
|
public class ApplicationWithConfigureMvcFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,24 +30,27 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
public async Task ApplicationWithCustomInputFiles_Works(RuntimeFlavor flavor)
|
public async Task ApplicationWithCustomInputFiles_Works(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
var expectedText = "Hello Index!";
|
var expectedText = "Hello Index!";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(expectedText, response.Trim());
|
Assert.Equal(expectedText, response.Trim());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled(RuntimeFlavor flavor)
|
public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
var expectedViews = new[]
|
var expectedViews = new[]
|
||||||
{
|
{
|
||||||
"/Views/Home/About.cshtml",
|
"/Views/Home/About.cshtml",
|
||||||
|
|
@ -55,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response2 = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"Home/GetPrecompiledResourceNames",
|
"Home/GetPrecompiledResourceNames",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
|
|
@ -64,13 +67,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
||||||
Assert.Equal(expectedViews, actual);
|
Assert.Equal(expectedViews, actual);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public void MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled(RuntimeFlavor flavor)
|
public async Task MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
var viewsNotPublished = new[]
|
var viewsNotPublished = new[]
|
||||||
{
|
{
|
||||||
"Index.cshtml",
|
"Index.cshtml",
|
||||||
|
|
@ -81,7 +86,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
{
|
{
|
||||||
"NotIncluded.cshtml",
|
"NotIncluded.cshtml",
|
||||||
};
|
};
|
||||||
var viewsDirectory = Path.Combine(Fixture.DeploymentResult.ContentRoot, "Views", "Home");
|
var viewsDirectory = Path.Combine(deployment.DeploymentResult.ContentRoot, "Views", "Home");
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
foreach (var file in viewsPublished)
|
foreach (var file in viewsPublished)
|
||||||
|
|
@ -96,6 +101,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
Assert.False(File.Exists(filePath), $"{filePath} was published.");
|
Assert.False(File.Exists(filePath), $"{filePath} was published.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ApplicationWithCustomInputFilesTestFixture : ApplicationTestFixture
|
public class ApplicationWithCustomInputFilesTestFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task Precompilation_WorksForViewsThatUseTagHelpers(string url, RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForViewsThatUseTagHelpers(string url, RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
$"Home/{url}",
|
$"Home/{url}",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.{url}.txt", response);
|
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.{url}.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ApplicationWithTagHelpersFixture : ApplicationTestFixture
|
public class ApplicationWithTagHelpersFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
@ -13,45 +14,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public abstract class ApplicationTestFixture : IDisposable
|
public abstract class ApplicationTestFixture : IDisposable
|
||||||
{
|
{
|
||||||
public const string DotnetCLITelemetryOptOut = "DOTNET_CLI_TELEMETRY_OPTOUT";
|
public const string DotnetCLITelemetryOptOut = "DOTNET_CLI_TELEMETRY_OPTOUT";
|
||||||
private IApplicationDeployer _deployer;
|
|
||||||
private HttpClient _httpClient;
|
|
||||||
|
|
||||||
protected ApplicationTestFixture(string applicationName)
|
protected ApplicationTestFixture(string applicationName)
|
||||||
{
|
{
|
||||||
ApplicationName = applicationName;
|
ApplicationName = applicationName;
|
||||||
|
LoggerFactory = CreateLoggerFactory();
|
||||||
|
Logger = LoggerFactory.CreateLogger($"{ApplicationName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ApplicationName { get; }
|
public string ApplicationName { get; }
|
||||||
|
|
||||||
public string ApplicationPath => ApplicationPaths.GetTestAppDirectory(ApplicationName);
|
public string ApplicationPath => ApplicationPaths.GetTestAppDirectory(ApplicationName);
|
||||||
|
|
||||||
public HttpClient HttpClient
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_httpClient == null)
|
|
||||||
{
|
|
||||||
if (DeploymentResult == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"{nameof(CreateDeployment)} must be called prior to accessing the {nameof(HttpClient)} property.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_httpClient = new HttpClient
|
|
||||||
{
|
|
||||||
BaseAddress = new Uri(DeploymentResult.ApplicationBaseUri),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return _httpClient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILogger Logger { get; private set; }
|
public ILogger Logger { get; private set; }
|
||||||
|
|
||||||
public ILoggerFactory LoggerFactory { get; private set; }
|
public ILoggerFactory LoggerFactory { get; private set; }
|
||||||
|
|
||||||
public DeploymentResult DeploymentResult { get; private set; }
|
|
||||||
|
|
||||||
public virtual DeploymentParameters GetDeploymentParameters(RuntimeFlavor flavor)
|
public virtual DeploymentParameters GetDeploymentParameters(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
return GetDeploymentParameters(ApplicationPath, flavor);
|
return GetDeploymentParameters(ApplicationPath, flavor);
|
||||||
|
|
@ -96,8 +74,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_httpClient?.Dispose();
|
|
||||||
_deployer?.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TryDeleteDirectory(string directory)
|
private static void TryDeleteDirectory(string directory)
|
||||||
|
|
@ -112,14 +88,35 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateDeployment(RuntimeFlavor flavor)
|
public async Task<Deployment> CreateDeploymentAsync(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
LoggerFactory = CreateLoggerFactory();
|
|
||||||
Logger = LoggerFactory.CreateLogger($"{ApplicationName}:{flavor}");
|
|
||||||
|
|
||||||
var deploymentParameters = GetDeploymentParameters(flavor);
|
var deploymentParameters = GetDeploymentParameters(flavor);
|
||||||
_deployer = ApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory);
|
var deployer = ApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory);
|
||||||
DeploymentResult = _deployer.DeployAsync().Result;
|
var deploymentResult = await deployer.DeployAsync();
|
||||||
|
|
||||||
|
return new Deployment(deployer, deploymentResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Deployment : IDisposable
|
||||||
|
{
|
||||||
|
public Deployment(IApplicationDeployer deployer, DeploymentResult deploymentResult)
|
||||||
|
{
|
||||||
|
Deployer = deployer;
|
||||||
|
DeploymentResult = deploymentResult;
|
||||||
|
HttpClient = deploymentResult.HttpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IApplicationDeployer Deployer { get; }
|
||||||
|
|
||||||
|
public HttpClient HttpClient { get; }
|
||||||
|
|
||||||
|
public DeploymentResult DeploymentResult { get; }
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Deployer.Dispose();
|
||||||
|
HttpClient.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
public async Task Precompilation_CanEmbedViewSourcesAsResources(RuntimeFlavor flavor)
|
public async Task Precompilation_CanEmbedViewSourcesAsResources(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
var expectedViews = new[]
|
var expectedViews = new[]
|
||||||
{
|
{
|
||||||
"/Areas/TestArea/Views/Home/Index.cshtml",
|
"/Areas/TestArea/Views/Home/Index.cshtml",
|
||||||
|
|
@ -40,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
var expectedText = "Hello Index!";
|
var expectedText = "Hello Index!";
|
||||||
|
|
||||||
// Act - 1
|
// Act - 1
|
||||||
var response1 = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response1 = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"Home/Index",
|
"Home/Index",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
|
|
@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
Assert.Equal(expectedText, response1.Trim());
|
Assert.Equal(expectedText, response1.Trim());
|
||||||
|
|
||||||
// Act - 2
|
// Act - 2
|
||||||
var response2 = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"Home/GetPrecompiledResourceNames",
|
"Home/GetPrecompiledResourceNames",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
|
|
@ -57,6 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
||||||
Assert.Equal(expectedViews, actual);
|
Assert.Equal(expectedViews, actual);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class PublishWithEmbedViewSourcesTestFixture : ApplicationTestFixture
|
public class PublishWithEmbedViewSourcesTestFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,97 +24,103 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task Precompilation_WorksForIndexPage_UsingFolderName(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForIndexPage_UsingFolderName(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"/",
|
"/",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task Precompilation_WorksForIndexPage_UsingFileName(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForIndexPage_UsingFileName(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"/Index",
|
"/Index",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task Precompilation_WorksForPageWithModel(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForPageWithModel(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"/PageWithModel?person=Dan",
|
"/PageWithModel?person=Dan",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response);
|
TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task Precompilation_WorksForPageWithRoute(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForPageWithRoute(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"/PageWithRoute/Dan",
|
"/PageWithRoute/Dan",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response);
|
TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task Precompilation_WorksForPageInNestedFolder(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForPageInNestedFolder(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"/Nested1/Nested2/PageWithTagHelper",
|
"/Nested1/Nested2/PageWithTagHelper",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response);
|
TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public async Task Precompilation_WorksWithPageConventions(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksWithPageConventions(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await RetryHelper.RetryRequest(
|
var response = await RetryHelper.RetryRequest(
|
||||||
() => Fixture.HttpClient.GetAsync("/Auth/Index"),
|
() => deployment.HttpClient.GetAsync("/Auth/Index"),
|
||||||
Fixture.Logger,
|
Fixture.Logger,
|
||||||
retryCount: 5);
|
retryCount: 5);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery);
|
Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class TestFixture : ApplicationTestFixture
|
public class TestFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,16 +24,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task Precompilation_WorksForSimpleApps(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForSimpleApps(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class SimpleAppTestFixture : ApplicationTestFixture
|
public class SimpleAppTestFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,16 +24,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task Precompilation_WorksForSimpleApps(RuntimeFlavor flavor)
|
public async Task Precompilation_WorksForSimpleApps(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
|
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class TestFixture : ApplicationTestFixture
|
public class TestFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task Precompilation_WorksForSimpleApps()
|
public async Task Precompilation_WorksForSimpleApps()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(RuntimeFlavor.Clr);
|
using (var deployment = await Fixture.CreateDeploymentAsync(RuntimeFlavor.Clr))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("SimpleAppX86DesktopOnly.Home.Index.txt", response);
|
TestEmbeddedResource.AssertContent("SimpleAppX86DesktopOnly.Home.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class SimpleAppX86DesktopOnlyFixture : ApplicationTestFixture
|
public class SimpleAppX86DesktopOnlyFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,16 +24,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
public async Task PrecompiledAssembliesUseSameStrongNameAsApplication(RuntimeFlavor flavor)
|
public async Task PrecompiledAssembliesUseSameStrongNameAsApplication(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act
|
// Act
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response);
|
TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class StrongNamedAppFixture : ApplicationTestFixture
|
public class StrongNamedAppFixture : ApplicationTestFixture
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
public void Precompilation_PreventsRefAssembliesFromBeingPublished(RuntimeFlavor flavor)
|
public async Task Precompilation_PreventsRefAssembliesFromBeingPublished(RuntimeFlavor flavor)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Fixture.CreateDeployment(flavor);
|
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||||
|
{
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
Assert.False(Directory.Exists(Path.Combine(Fixture.DeploymentResult.ContentRoot, "refs")));
|
Assert.False(Directory.Exists(Path.Combine(deployment.DeploymentResult.ContentRoot, "refs")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue