Fix functional tests to properly dispose of their app deployer.
This commit is contained in:
parent
4a308f1e9d
commit
2dbe4b79c4
|
|
@ -24,14 +24,14 @@ 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
|
||||||
|
var response = await deployment.HttpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger);
|
||||||
|
|
||||||
// Act
|
// Assert
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger);
|
TestEmbeddedResource.AssertContent("ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt", response);
|
||||||
|
}
|
||||||
// Assert
|
|
||||||
TestEmbeddedResource.AssertContent("ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt", response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ApplicationConsumingPrecompiledViewsFixture : ApplicationTestFixture
|
public class ApplicationConsumingPrecompiledViewsFixture : ApplicationTestFixture
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,16 @@ 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
|
||||||
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
|
Fixture.Logger);
|
||||||
|
|
||||||
// Act
|
// Assert
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.Index.txt", response);
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
}
|
||||||
Fixture.Logger);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.Index.txt", response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
|
|
@ -41,15 +42,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
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,15 +25,17 @@ 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]
|
||||||
|
|
@ -41,17 +43,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
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);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestEmbeddedResource.AssertContent(
|
TestEmbeddedResource.AssertContent(
|
||||||
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
|
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
|
||||||
response);
|
response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ApplicationWithConfigureMvcFixture : ApplicationTestFixture
|
public class ApplicationWithConfigureMvcFixture : ApplicationTestFixture
|
||||||
|
|
|
||||||
|
|
@ -30,16 +30,18 @@ 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]
|
||||||
|
|
@ -47,53 +49,57 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
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",
|
||||||
"/Views/Home/Index.cshtml",
|
"/Views/Home/Index.cshtml",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response2 = await Fixture.HttpClient.GetStringWithRetryAsync(
|
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
"Home/GetPrecompiledResourceNames",
|
"Home/GetPrecompiledResourceNames",
|
||||||
Fixture.Logger);
|
Fixture.Logger);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
.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[]
|
|
||||||
{
|
{
|
||||||
"Index.cshtml",
|
var viewsNotPublished = new[]
|
||||||
"About.cshtml",
|
{
|
||||||
};
|
"Index.cshtml",
|
||||||
|
"About.cshtml",
|
||||||
|
};
|
||||||
|
|
||||||
var viewsPublished = new[]
|
var viewsPublished = new[]
|
||||||
{
|
{
|
||||||
"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)
|
||||||
{
|
{
|
||||||
var filePath = Path.Combine(viewsDirectory, file);
|
var filePath = Path.Combine(viewsDirectory, file);
|
||||||
Assert.True(File.Exists(filePath), $"{filePath} was not published.");
|
Assert.True(File.Exists(filePath), $"{filePath} was not published.");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var file in viewsNotPublished)
|
foreach (var file in viewsNotPublished)
|
||||||
{
|
{
|
||||||
var filePath = Path.Combine(viewsDirectory, file);
|
var filePath = Path.Combine(viewsDirectory, file);
|
||||||
Assert.False(File.Exists(filePath), $"{filePath} was published.");
|
Assert.False(File.Exists(filePath), $"{filePath} was published.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,15 +46,16 @@ 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,32 +30,34 @@ 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[]
|
|
||||||
{
|
{
|
||||||
"/Areas/TestArea/Views/Home/Index.cshtml",
|
var expectedViews = new[]
|
||||||
"/Views/Home/About.cshtml",
|
{
|
||||||
"/Views/Home/Index.cshtml",
|
"/Areas/TestArea/Views/Home/Index.cshtml",
|
||||||
};
|
"/Views/Home/About.cshtml",
|
||||||
var expectedText = "Hello Index!";
|
"/Views/Home/Index.cshtml",
|
||||||
|
};
|
||||||
|
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);
|
||||||
|
|
||||||
// Assert - 1
|
// Assert - 1
|
||||||
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);
|
||||||
|
|
||||||
// Assert - 2
|
// Assert - 2
|
||||||
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
.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,15 +24,16 @@ 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]
|
||||||
|
|
@ -40,15 +41,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
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]
|
||||||
|
|
@ -56,15 +58,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
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]
|
||||||
|
|
@ -72,15 +75,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
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]
|
||||||
|
|
@ -88,15 +92,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
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]
|
||||||
|
|
@ -104,16 +109,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
||||||
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,15 +24,16 @@ 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
|
||||||
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
|
Fixture.Logger);
|
||||||
|
|
||||||
// Act
|
// Assert
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
}
|
||||||
Fixture.Logger);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SimpleAppTestFixture : ApplicationTestFixture
|
public class SimpleAppTestFixture : ApplicationTestFixture
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,16 @@ 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
|
||||||
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
|
Fixture.Logger);
|
||||||
|
|
||||||
// Act
|
// Assert
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
}
|
||||||
Fixture.Logger);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestFixture : ApplicationTestFixture
|
public class TestFixture : ApplicationTestFixture
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,16 @@ 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
|
||||||
|
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||||
|
deployment.DeploymentResult.ApplicationBaseUri,
|
||||||
|
Fixture.Logger);
|
||||||
|
|
||||||
// Act
|
// Assert
|
||||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
TestEmbeddedResource.AssertContent("SimpleAppX86DesktopOnly.Home.Index.txt", response);
|
||||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
}
|
||||||
Fixture.Logger);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
TestEmbeddedResource.AssertContent("SimpleAppX86DesktopOnly.Home.Index.txt", response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SimpleAppX86DesktopOnlyFixture : ApplicationTestFixture
|
public class SimpleAppX86DesktopOnlyFixture : ApplicationTestFixture
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,16 @@ 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