Fix functional tests to properly dispose of their app deployer.
This commit is contained in:
Родитель
4a308f1e9d
Коммит
2dbe4b79c4
|
@ -24,14 +24,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||
public async Task ConsumingClassLibrariesWithPrecompiledViewsWork(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationConsumingPrecompiledViews.Manage.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class ApplicationConsumingPrecompiledViewsFixture : ApplicationTestFixture
|
||||
|
|
|
@ -25,15 +25,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForViewsUsingRelativePath(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
deployment.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -41,15 +42,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForViewsUsingDirectoryTraversal(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
deployment.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.About.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationUsingRelativePaths.Home.About.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class ApplicationUsingRelativePathsTestFixture : ApplicationTestFixture
|
||||
|
|
|
@ -25,15 +25,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_RunsConfiguredCompilationCallbacks(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
deployment.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -41,17 +43,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_UsesConfiguredParseOptions(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"Home/ViewWithPreprocessor",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent(
|
||||
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
|
||||
response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent(
|
||||
"ApplicationWithConfigureMvc.Home.ViewWithPreprocessor.txt",
|
||||
response);
|
||||
}
|
||||
}
|
||||
|
||||
public class ApplicationWithConfigureMvcFixture : ApplicationTestFixture
|
||||
|
|
|
@ -30,16 +30,18 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
|||
public async Task ApplicationWithCustomInputFiles_Works(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
var expectedText = "Hello Index!";
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
var expectedText = "Hello Index!";
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
deployment.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedText, response.Trim());
|
||||
// Assert
|
||||
Assert.Equal(expectedText, response.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -47,53 +49,57 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
|||
public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
var expectedViews = new[]
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
var expectedViews = new[]
|
||||
{
|
||||
"/Views/Home/About.cshtml",
|
||||
"/Views/Home/Index.cshtml",
|
||||
};
|
||||
|
||||
// Act
|
||||
var response2 = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
"Home/GetPrecompiledResourceNames",
|
||||
Fixture.Logger);
|
||||
// Act
|
||||
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"Home/GetPrecompiledResourceNames",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
||||
Assert.Equal(expectedViews, actual);
|
||||
// Assert
|
||||
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
||||
Assert.Equal(expectedViews, actual);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||
public void MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled(RuntimeFlavor flavor)
|
||||
public async Task MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
var viewsNotPublished = new[]
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
"Index.cshtml",
|
||||
"About.cshtml",
|
||||
};
|
||||
var viewsNotPublished = new[]
|
||||
{
|
||||
"Index.cshtml",
|
||||
"About.cshtml",
|
||||
};
|
||||
|
||||
var viewsPublished = new[]
|
||||
{
|
||||
"NotIncluded.cshtml",
|
||||
};
|
||||
var viewsDirectory = Path.Combine(Fixture.DeploymentResult.ContentRoot, "Views", "Home");
|
||||
var viewsPublished = new[]
|
||||
{
|
||||
"NotIncluded.cshtml",
|
||||
};
|
||||
var viewsDirectory = Path.Combine(deployment.DeploymentResult.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.");
|
||||
}
|
||||
// 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.");
|
||||
foreach (var file in viewsNotPublished)
|
||||
{
|
||||
var filePath = Path.Combine(viewsDirectory, file);
|
||||
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)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
$"Home/{url}",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.{url}.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.{url}.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class ApplicationWithTagHelpersFixture : ApplicationTestFixture
|
||||
|
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
@ -13,45 +14,22 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public abstract class ApplicationTestFixture : IDisposable
|
||||
{
|
||||
public const string DotnetCLITelemetryOptOut = "DOTNET_CLI_TELEMETRY_OPTOUT";
|
||||
private IApplicationDeployer _deployer;
|
||||
private HttpClient _httpClient;
|
||||
|
||||
protected ApplicationTestFixture(string applicationName)
|
||||
{
|
||||
ApplicationName = applicationName;
|
||||
LoggerFactory = CreateLoggerFactory();
|
||||
Logger = LoggerFactory.CreateLogger($"{ApplicationName}");
|
||||
}
|
||||
|
||||
public string ApplicationName { get; }
|
||||
|
||||
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 ILoggerFactory LoggerFactory { get; private set; }
|
||||
|
||||
public DeploymentResult DeploymentResult { get; private set; }
|
||||
|
||||
public virtual DeploymentParameters GetDeploymentParameters(RuntimeFlavor flavor)
|
||||
{
|
||||
return GetDeploymentParameters(ApplicationPath, flavor);
|
||||
|
@ -96,8 +74,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
_httpClient?.Dispose();
|
||||
_deployer?.Dispose();
|
||||
}
|
||||
|
||||
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);
|
||||
_deployer = ApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory);
|
||||
DeploymentResult = _deployer.DeployAsync().Result;
|
||||
var deployer = ApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory);
|
||||
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)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
var expectedViews = new[]
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
"/Areas/TestArea/Views/Home/Index.cshtml",
|
||||
"/Views/Home/About.cshtml",
|
||||
"/Views/Home/Index.cshtml",
|
||||
};
|
||||
var expectedText = "Hello Index!";
|
||||
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 Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
"Home/Index",
|
||||
Fixture.Logger);
|
||||
// Act - 1
|
||||
var response1 = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"Home/Index",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert - 1
|
||||
Assert.Equal(expectedText, response1.Trim());
|
||||
// Assert - 1
|
||||
Assert.Equal(expectedText, response1.Trim());
|
||||
|
||||
// Act - 2
|
||||
var response2 = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
"Home/GetPrecompiledResourceNames",
|
||||
Fixture.Logger);
|
||||
// Act - 2
|
||||
var response2 = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"Home/GetPrecompiledResourceNames",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert - 2
|
||||
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
||||
Assert.Equal(expectedViews, actual);
|
||||
// Assert - 2
|
||||
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
||||
Assert.Equal(expectedViews, actual);
|
||||
}
|
||||
}
|
||||
|
||||
public class PublishWithEmbedViewSourcesTestFixture : ApplicationTestFixture
|
||||
|
|
|
@ -24,15 +24,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForIndexPage_UsingFolderName(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"/",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -40,15 +41,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForIndexPage_UsingFileName(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"/Index",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -56,15 +58,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForPageWithModel(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"/PageWithModel?person=Dan",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.PageWithModel.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -72,15 +75,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForPageWithRoute(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"/PageWithRoute/Dan",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.PageWithRoute.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -88,15 +92,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForPageInNestedFolder(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
"/Nested1/Nested2/PageWithTagHelper",
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("RazorPages.Nested1.Nested2.PageWithTagHelper.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
@ -104,16 +109,17 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksWithPageConventions(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await RetryHelper.RetryRequest(
|
||||
() => Fixture.HttpClient.GetAsync("/Auth/Index"),
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await RetryHelper.RetryRequest(
|
||||
() => deployment.HttpClient.GetAsync("/Auth/Index"),
|
||||
Fixture.Logger,
|
||||
retryCount: 5);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery);
|
||||
// Assert
|
||||
Assert.Equal("/Login?ReturnUrl=%2FAuth%2FIndex", response.RequestMessage.RequestUri.PathAndQuery);
|
||||
}
|
||||
}
|
||||
|
||||
public class TestFixture : ApplicationTestFixture
|
||||
|
|
|
@ -24,15 +24,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForSimpleApps(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
deployment.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleAppTestFixture : ApplicationTestFixture
|
||||
|
|
|
@ -24,15 +24,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForSimpleApps(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
deployment.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppWithAssemblyRenameTest.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class TestFixture : ApplicationTestFixture
|
||||
|
|
|
@ -20,15 +20,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task Precompilation_WorksForSimpleApps()
|
||||
{
|
||||
// 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
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppX86DesktopOnly.Home.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppX86DesktopOnly.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleAppX86DesktopOnlyFixture : ApplicationTestFixture
|
||||
|
|
|
@ -24,15 +24,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
public async Task PrecompiledAssembliesUseSameStrongNameAsApplication(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act
|
||||
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||
Fixture.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act
|
||||
var response = await deployment.HttpClient.GetStringWithRetryAsync(
|
||||
deployment.DeploymentResult.ApplicationBaseUri,
|
||||
Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response);
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("StrongNamedApp.Home.Index.txt", response);
|
||||
}
|
||||
}
|
||||
|
||||
public class StrongNamedAppFixture : ApplicationTestFixture
|
||||
|
|
|
@ -23,13 +23,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
|
|||
|
||||
[ConditionalTheory]
|
||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||
public void Precompilation_PreventsRefAssembliesFromBeingPublished(RuntimeFlavor flavor)
|
||||
public async Task Precompilation_PreventsRefAssembliesFromBeingPublished(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
Fixture.CreateDeployment(flavor);
|
||||
|
||||
// Act & Assert
|
||||
Assert.False(Directory.Exists(Path.Combine(Fixture.DeploymentResult.ContentRoot, "refs")));
|
||||
using (var deployment = await Fixture.CreateDeploymentAsync(flavor))
|
||||
{
|
||||
// Act & Assert
|
||||
Assert.False(Directory.Exists(Path.Combine(deployment.DeploymentResult.ContentRoot, "refs")));
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory]
|
||||
|
|
Загрузка…
Ссылка в новой задаче