[Fixes #6468] Clean up the productionized testing infrastructure
This commit is contained in:
parent
7c5a16c105
commit
d917504c14
28
Mvc.sln
28
Mvc.sln
|
|
@ -24,8 +24,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Fu
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicWebSite", "test\WebSites\BasicWebSite\BasicWebSite.csproj", "{34DF1487-12C6-476C-BE0A-F31DF1939AE5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.TestConfiguration", "test\WebSites\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj", "{680D75ED-601F-4D86-B01B-1072D0C31B8C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoutingWebSite", "test\WebSites\RoutingWebSite\RoutingWebSite.csproj", "{42CDBF4A-E238-4C0F-A416-44588363EB4C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Test", "test\Microsoft.AspNetCore.Mvc.Test\Microsoft.AspNetCore.Mvc.Test.csproj", "{5F945B82-FE5F-425C-956C-8BC2F2020254}"
|
||||
|
|
@ -124,8 +122,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Pe
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Testing", "src\Microsoft.AspNetCore.Mvc.Testing\Microsoft.AspNetCore.Mvc.Testing.csproj", "{7500B228-1769-4CFB-A571-3DFAC6678A06}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Mvc.Testing.Xunit", "src\Microsoft.AspNetCore.Mvc.Testing.Xunit\Microsoft.AspNetCore.Mvc.Testing.Xunit.csproj", "{5248D809-E5E5-49FE-B3E8-428D454C63B3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -206,16 +202,6 @@ Global
|
|||
{34DF1487-12C6-476C-BE0A-F31DF1939AE5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{34DF1487-12C6-476C-BE0A-F31DF1939AE5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{34DF1487-12C6-476C-BE0A-F31DF1939AE5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{42CDBF4A-E238-4C0F-A416-44588363EB4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{42CDBF4A-E238-4C0F-A416-44588363EB4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{42CDBF4A-E238-4C0F-A416-44588363EB4C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -772,18 +758,6 @@ Global
|
|||
{7500B228-1769-4CFB-A571-3DFAC6678A06}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{7500B228-1769-4CFB-A571-3DFAC6678A06}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7500B228-1769-4CFB-A571-3DFAC6678A06}.Release|x86.Build.0 = Release|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -797,7 +771,6 @@ Global
|
|||
{16703B76-C9F7-4C75-AE6C-53D92E308E3C} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{323D0C04-B518-4A8F-8A8E-3546AD153D34} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{34DF1487-12C6-476C-BE0A-F31DF1939AE5} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{680D75ED-601F-4D86-B01B-1072D0C31B8C} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{42CDBF4A-E238-4C0F-A416-44588363EB4C} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{5F945B82-FE5F-425C-956C-8BC2F2020254} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{B07CAF59-11ED-40E3-A5DB-E1178F84FA78} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
|
|
@ -847,7 +820,6 @@ Global
|
|||
{4BA6EC9A-B6D9-41F2-BFDA-D82B22D80352} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{F16CEE0D-A28E-43BD-802F-99BAFE4BA7CE} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{7500B228-1769-4CFB-A571-3DFAC6678A06} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{5248D809-E5E5-49FE-B3E8-428D454C63B3} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {63D344F6-F86D-40E6-85B9-0AABBE338C4A}
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
// 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.Globalization;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Xunit.Internal
|
||||
{
|
||||
internal class CultureReplacer : IDisposable
|
||||
{
|
||||
private const string _defaultCultureName = "en-GB";
|
||||
private const string _defaultUICultureName = "en-US";
|
||||
private static readonly CultureInfo _defaultCulture = new CultureInfo(_defaultCultureName);
|
||||
private readonly CultureInfo _originalCulture;
|
||||
private readonly CultureInfo _originalUICulture;
|
||||
private readonly long _threadId;
|
||||
|
||||
// Culture => Formatting of dates/times/money/etc, defaults to en-GB because en-US is the same as InvariantCulture
|
||||
// We want to be able to find issues where the InvariantCulture is used, but a specific culture should be.
|
||||
//
|
||||
// UICulture => Language
|
||||
public CultureReplacer(string culture = _defaultCultureName, string uiCulture = _defaultUICultureName)
|
||||
: this(new CultureInfo(culture), new CultureInfo(uiCulture))
|
||||
{
|
||||
}
|
||||
|
||||
public CultureReplacer(CultureInfo culture, CultureInfo uiCulture)
|
||||
{
|
||||
_originalCulture = CultureInfo.CurrentCulture;
|
||||
_originalUICulture = CultureInfo.CurrentUICulture;
|
||||
_threadId = Thread.CurrentThread.ManagedThreadId;
|
||||
CultureInfo.CurrentCulture = culture;
|
||||
CultureInfo.CurrentUICulture = uiCulture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the culture that is used as the default value for CultureInfo.DefaultThreadCurrentCulture when CultureReplacer is used.
|
||||
/// </summary>
|
||||
public static string DefaultCultureName
|
||||
{
|
||||
get { return _defaultCultureName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the culture that is used as the default value for [Thread.CurrentThread(NET45)/CultureInfo(K10)].CurrentUICulture when CultureReplacer is used.
|
||||
/// </summary>
|
||||
public static string DefaultUICultureName
|
||||
{
|
||||
get { return _defaultUICultureName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The culture that is used as the default value for [Thread.CurrentThread(NET45)/CultureInfo(K10)].CurrentCulture when CultureReplacer is used.
|
||||
/// </summary>
|
||||
public static CultureInfo DefaultCulture
|
||||
{
|
||||
get { return _defaultCulture; }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if(Thread.CurrentThread.ManagedThreadId != _threadId)
|
||||
{
|
||||
throw new InvalidOperationException("The current thread is not the same as the thread " +
|
||||
"invoking the constructor. This should never happen.");
|
||||
}
|
||||
|
||||
CultureInfo.CurrentCulture = _originalCulture;
|
||||
CultureInfo.CurrentUICulture = _originalUICulture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
// 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.Http;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Xunit.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// A middleware that ensures web sites run in a consistent culture. Currently useful for tests that format dates,
|
||||
/// times, or numbers. Will be more useful when we have localized resources.
|
||||
/// </summary>
|
||||
public class CultureReplacerMiddleware
|
||||
{
|
||||
// Have no current need to use cultures other than the ReplaceCultureAttribute defaults (en-GB, en-US).
|
||||
private readonly ReplaceCultureAttribute _replaceCulture = new ReplaceCultureAttribute();
|
||||
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public CultureReplacerMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
// Use ReplaceCultureAttribute to avoid thread consistency checks in CultureReplacer. await doesn't
|
||||
// necessarily end on the original thread. For this case, problems arise when next middleware throws. Can
|
||||
// remove the thread consistency checks once culture is (at least for .NET 4.6) handled using
|
||||
// AsyncLocal<CultureInfo>.
|
||||
try
|
||||
{
|
||||
_replaceCulture.Before(methodUnderTest: null);
|
||||
await _next(context);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_replaceCulture.After(methodUnderTest: null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
// 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.Globalization;
|
||||
using System.Reflection;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Xunit.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Replaces the current culture and UI culture for the test.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
internal class ReplaceCultureAttribute : BeforeAfterTestAttribute
|
||||
{
|
||||
private const string _defaultCultureName = "en-GB";
|
||||
private const string _defaultUICultureName = "en-US";
|
||||
private CultureInfo _originalCulture;
|
||||
private CultureInfo _originalUICulture;
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the current culture and UI culture to en-GB and en-US respectively.
|
||||
/// </summary>
|
||||
public ReplaceCultureAttribute() :
|
||||
this(_defaultCultureName, _defaultUICultureName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the current culture and UI culture based on specified values.
|
||||
/// </summary>
|
||||
public ReplaceCultureAttribute(string currentCulture, string currentUICulture)
|
||||
{
|
||||
Culture = new CultureInfo(currentCulture);
|
||||
UICulture = new CultureInfo(currentUICulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="CultureInfo.CurrentCulture"/> for the test. Defaults to en-GB.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// en-GB is used here as the default because en-US is equivalent to the InvariantCulture. We
|
||||
/// want to be able to find bugs where we're accidentally relying on the Invariant instead of the
|
||||
/// user's culture.
|
||||
/// </remarks>
|
||||
public CultureInfo Culture { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="CultureInfo.CurrentUICulture"/> for the test. Defaults to en-US.
|
||||
/// </summary>
|
||||
public CultureInfo UICulture { get; }
|
||||
|
||||
public override void Before(MethodInfo methodUnderTest)
|
||||
{
|
||||
_originalCulture = CultureInfo.CurrentCulture;
|
||||
_originalUICulture = CultureInfo.CurrentUICulture;
|
||||
|
||||
CultureInfo.CurrentCulture = Culture;
|
||||
CultureInfo.CurrentUICulture = UICulture;
|
||||
}
|
||||
|
||||
public override void After(MethodInfo methodUnderTest)
|
||||
{
|
||||
CultureInfo.CurrentCulture = _originalCulture;
|
||||
CultureInfo.CurrentUICulture = _originalUICulture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>XUnit convenience fixture for creating functional tests for MVC applications.</Description>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>aspnetcore;aspnetcoremvc;aspnetcoremvctesting</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="build\**\*.targets" Pack="true" PackagePath="%(Identity)" />
|
||||
<Content Include="build\**\xunit.runner.json" Pack="true" PackagePath="%(Identity)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Testing\Microsoft.AspNetCore.Mvc.Testing.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<Target Name="CopyXunitRunner" AfterTargets="Build" Condition="'$(TargetFramework)'!=''">
|
||||
<ItemGroup>
|
||||
<XunitRunnerJson Include="$(MSBuildThisFileDirectory)xunit.runner.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ShouldCopyXUnitRunnerJson Condition="Exists('%(XunitRunnerJson.FullPath)') and !Exists('$(OutputPath)xunit.runner.json') and '$(DisableCopyXunitRunnerJson)' == ''" >true</ShouldCopyXUnitRunnerJson>
|
||||
</PropertyGroup>
|
||||
<Copy SourceFiles="%(XunitRunnerJson.FullPath)" DestinationFolder="$(OutputPath)" Condition="'$(ShouldCopyXUnitRunnerJson)' != ''" />
|
||||
<Message Condition="'$(ShouldCopyXUnitRunnerJson)' != ''" Text="Automatically copied 'xunit.runner.json' to '$(OutputPath)'. Set a non-empty value to 'DisableCopyXunitRunnerJson' to disable this behavior. You will have to manually configure 'shadowCopy: false' for functional tests to run properly." />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// 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.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Delegating handler for managing cookies on functional tests.
|
||||
/// </summary>
|
||||
public class CookieContainerHandler : DelegatingHandler
|
||||
{
|
||||
public CookieContainerHandler(HttpMessageHandler innerHandler)
|
||||
: base(innerHandler)
|
||||
{
|
||||
}
|
||||
|
||||
public CookieContainer Container { get; } = new CookieContainer();
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
var cookieHeader = Container.GetCookieHeader(request.RequestUri);
|
||||
request.Headers.Add("Cookie", cookieHeader);
|
||||
|
||||
var response = await base.SendAsync(request, cancellationToken);
|
||||
|
||||
if (response.Headers.TryGetValues("Set-Cookie", out var setCookieHeaders))
|
||||
{
|
||||
foreach (var header in setCookieHeaders)
|
||||
{
|
||||
Container.SetCookies(response.RequestMessage.RequestUri, header);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
// 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.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.TestConfiguration
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// A middleware that ensures web sites run in a consistent culture. Currently useful for tests that format dates,
|
||||
|
|
@ -14,16 +13,21 @@ namespace Microsoft.AspNetCore.Mvc.TestConfiguration
|
|||
/// </summary>
|
||||
public class CultureReplacerMiddleware
|
||||
{
|
||||
// Have no current need to use cultures other than the ReplaceCultureAttribute defaults (en-GB, en-US).
|
||||
private readonly ReplaceCultureAttribute _replaceCulture = new ReplaceCultureAttribute();
|
||||
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public CultureReplacerMiddleware(RequestDelegate next)
|
||||
private CultureInfo _originalCulture;
|
||||
private CultureInfo _originalUICulture;
|
||||
|
||||
public CultureReplacerMiddleware(RequestDelegate next, TestCulture culture)
|
||||
{
|
||||
Culture = new CultureInfo(culture.Culture);
|
||||
UICulture = new CultureInfo(culture.UICulture);
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public CultureInfo UICulture { get; }
|
||||
public CultureInfo Culture { get; }
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
// Use ReplaceCultureAttribute to avoid thread consistency checks in CultureReplacer. await doesn't
|
||||
|
|
@ -32,12 +36,18 @@ namespace Microsoft.AspNetCore.Mvc.TestConfiguration
|
|||
// AsyncLocal<CultureInfo>.
|
||||
try
|
||||
{
|
||||
_replaceCulture.Before(methodUnderTest: null);
|
||||
_originalCulture = CultureInfo.CurrentCulture;
|
||||
_originalUICulture = CultureInfo.CurrentUICulture;
|
||||
|
||||
CultureInfo.CurrentCulture = Culture;
|
||||
CultureInfo.CurrentUICulture = UICulture;
|
||||
|
||||
await _next(context);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_replaceCulture.After(methodUnderTest: null);
|
||||
CultureInfo.CurrentCulture = _originalCulture;
|
||||
CultureInfo.CurrentUICulture = _originalUICulture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Xunit.Internal
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Inserts the <see cref="CultureReplacerMiddleware"/> at the beginning of the pipeline.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// 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.
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing.Internal
|
||||
{
|
||||
public class TestCulture
|
||||
{
|
||||
public string Culture { get; set; }
|
||||
public string UICulture { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -3,15 +3,18 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.Testing.Internal;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing
|
||||
{
|
||||
|
|
@ -21,6 +24,8 @@ namespace Microsoft.AspNetCore.Mvc.Testing
|
|||
/// <typeparam name="TStartup">The application startup class.</typeparam>
|
||||
public class MvcWebApplicationBuilder<TStartup> where TStartup : class
|
||||
{
|
||||
private TestCulture _systemCulture;
|
||||
|
||||
public string ContentRoot { get; set; }
|
||||
public IList<Action<IServiceCollection>> ConfigureServicesBeforeStartup { get; set; } = new List<Action<IServiceCollection>>();
|
||||
public IList<Action<IServiceCollection>> ConfigureServicesAfterStartup { get; set; } = new List<Action<IServiceCollection>>();
|
||||
|
|
@ -56,13 +61,17 @@ namespace Microsoft.AspNetCore.Mvc.Testing
|
|||
public MvcWebApplicationBuilder<TStartup> UseApplicationAssemblies()
|
||||
{
|
||||
var depsFileName = $"{typeof(TStartup).Assembly.GetName().Name}.deps.json";
|
||||
var depsFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), depsFileName));
|
||||
var depsFile = new FileInfo(Path.Combine(AppContext.BaseDirectory, depsFileName));
|
||||
if (!depsFile.Exists)
|
||||
{
|
||||
throw new InvalidOperationException($"Can't find'{depsFile}'. This file is required for functional tests " +
|
||||
$"to run properly. There should be a copy of the file on your source project bin folder. If thats not the " +
|
||||
$"case, make sure that the property PreserveCompilationContext is set to true on your project file. E.g" +
|
||||
$"'<PreserveCompilationContext>true</PreserveCompilationContext>'.");
|
||||
throw new InvalidOperationException($"Can't find'{depsFile.FullName}'. This file is required for functional tests " +
|
||||
"to run properly. There should be a copy of the file on your source project bin folder. If thats not the " +
|
||||
"case, make sure that the property PreserveCompilationContext is set to true on your project file. E.g" +
|
||||
"'<PreserveCompilationContext>true</PreserveCompilationContext>'." +
|
||||
$"For functional tests to work they need to either run from the build output folder or the {Path.GetFileName(depsFile.FullName)} " +
|
||||
$"file from your application's output directory must be copied" +
|
||||
"to the folder where the tests are running on. A common cause for this error is having shadow copying enabled when the" +
|
||||
"tests run.");
|
||||
}
|
||||
|
||||
ApplicationAssemblies.AddRange(DefaultAssemblyPartDiscoveryProvider
|
||||
|
|
@ -73,6 +82,44 @@ namespace Microsoft.AspNetCore.Mvc.Testing
|
|||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up an <see cref="IStartupFilter"/> that configures the <see cref="CultureReplacerMiddleware"/> at the
|
||||
/// beginning of the pipeline to change the <see cref="CultureInfo.CurrentCulture"/> and <see cref="CultureInfo.CurrentUICulture"/>
|
||||
/// of the thread so that they match the cultures in <paramref name="culture"/> and <paramref name="uiCulture"/> for the rest of the
|
||||
/// <see cref="HttpRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="culture">The culture to use when processing <see cref="HttpRequest"/>.</param>
|
||||
/// <param name="uiCulture">The UI culture to use when processing <see cref="HttpRequest"/>.</param>
|
||||
/// <returns>An instance of this <see cref="MvcWebApplicationBuilder{TStartup}"/></returns>
|
||||
public MvcWebApplicationBuilder<TStartup> UseRequestCulture(string culture, string uiCulture)
|
||||
{
|
||||
ConfigureBeforeStartup(services =>
|
||||
{
|
||||
services.TryAddSingleton(new TestCulture
|
||||
{
|
||||
Culture = culture,
|
||||
UICulture = uiCulture
|
||||
});
|
||||
services.TryAddSingleton<IStartupFilter, CultureReplacerStartupFilter>();
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the <see cref="CultureInfo.CurrentCulture"/> and the <see cref="CultureInfo.CurrentUICulture"/>
|
||||
/// of the system during the initial configuration of the <see cref="TestHost"/> in case there is any middleware
|
||||
/// that captures the current culture of the system when the pipeline is being constructed.
|
||||
/// </summary>
|
||||
/// <param name="culture">The culture to use when processing <see cref="HttpRequest"/>.</param>
|
||||
/// <param name="uiCulture">The UI culture to use when processing <see cref="HttpRequest"/>.</param>
|
||||
/// <returns>An instance of this <see cref="MvcWebApplicationBuilder{TStartup}"/></returns>
|
||||
public MvcWebApplicationBuilder<TStartup> UseStartupCulture(string culture, string uiCulture)
|
||||
{
|
||||
_systemCulture = new TestCulture { Culture = culture, UICulture = uiCulture };
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the application content root.
|
||||
/// </summary>
|
||||
|
|
@ -113,7 +160,19 @@ namespace Microsoft.AspNetCore.Mvc.Testing
|
|||
.UseContentRoot(ContentRoot)
|
||||
.ConfigureServices(InitializeServices);
|
||||
|
||||
return new TestServer(builder);
|
||||
var originalCulture = CultureInfo.CurrentCulture;
|
||||
var originalUICulture = CultureInfo.CurrentUICulture;
|
||||
try
|
||||
{
|
||||
CultureInfo.CurrentCulture = new CultureInfo(_systemCulture.Culture);
|
||||
CultureInfo.CurrentUICulture = new CultureInfo(_systemCulture.UICulture);
|
||||
return new TestServer(builder);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CultureInfo.CurrentCulture = originalCulture;
|
||||
CultureInfo.CurrentUICulture = originalUICulture;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void InitializeServices(IServiceCollection services)
|
||||
|
|
|
|||
|
|
@ -6,18 +6,15 @@ using System.IO;
|
|||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.AspNetCore.Mvc.Testing.Xunit.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.Testing.Internal;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||
namespace Microsoft.AspNetCore.Mvc.Testing
|
||||
{
|
||||
/// <summary>
|
||||
/// XUnit fixture for bootstrapping an application in memory for functional end to end tests.
|
||||
/// Fixture for bootstrapping an application in memory for functional end to end tests.
|
||||
/// </summary>
|
||||
/// <typeparam name="TStartup">The applications startup class.</typeparam>
|
||||
public class WebApplicationTestFixture<TStartup> : IDisposable where TStartup : class
|
||||
|
|
@ -43,30 +40,12 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
var projectPath = Path.Combine(solutionRelativePath, projectName);
|
||||
var builder = new MvcWebApplicationBuilder<TStartup>()
|
||||
.UseSolutionRelativeContentRoot(projectPath)
|
||||
.UseApplicationAssemblies();
|
||||
.UseApplicationAssemblies()
|
||||
.UseRequestCulture("en-GB", "en-US")
|
||||
.UseStartupCulture("en-GB", "en-US");
|
||||
|
||||
ConfigureApplication(builder);
|
||||
|
||||
var xunitRunnerJson = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "xunit.runner.json"));
|
||||
if (!xunitRunnerJson.Exists)
|
||||
{
|
||||
Console.WriteLine("Can't find xunit.runner.json. " +
|
||||
"Functional tests require '\"shadowCopy\": false' to work properly. " +
|
||||
"Make sure your XUnit configuration has that setup.");
|
||||
}
|
||||
|
||||
var content = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(xunitRunnerJson.FullName));
|
||||
if (!content.TryGetValue("shadowCopy", out var token) || !(bool)token)
|
||||
{
|
||||
Console.WriteLine("'shadowCopy' is not set to true on xunit.runner.json. " +
|
||||
"Functional tests require '\"shadowCopy\": false' to work properly. " +
|
||||
"Make sure your XUnit configuration has that setup.");
|
||||
}
|
||||
|
||||
using (new CultureReplacer())
|
||||
{
|
||||
_server = builder.Build();
|
||||
}
|
||||
_server = builder.Build();
|
||||
|
||||
Client = _server.CreateClient();
|
||||
Client.BaseAddress = new Uri("http://localhost");
|
||||
|
|
@ -81,8 +60,16 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
builder.ConfigureAfterStartup(s => s.TryAddEnumerable(ServiceDescriptor.Transient<IStartupFilter, CultureReplacerStartupFilter>()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an instance of the <see cref="HttpClient"/> used to send <see cref="HttpRequestMessage"/> to the server.
|
||||
/// </summary>
|
||||
public HttpClient Client { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of an <see cref="HttpClient"/> that can be used to
|
||||
/// send <see cref="HttpRequestMessage"/> to the server.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="HttpClient"/></returns>
|
||||
public HttpClient CreateClient()
|
||||
{
|
||||
var client = _server.CreateClient();
|
||||
|
|
@ -91,9 +78,17 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
return client;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of an <see cref="HttpClient"/> that can be used to
|
||||
/// send <see cref="HttpRequestMessage"/> to the server.
|
||||
/// </summary>
|
||||
/// <param name="baseAddress">The base address of the <see cref="HttpClient"/> instance.</param>
|
||||
/// <param name="handlers">A list of <see cref="DelegatingHandler"/> instances to setup on the
|
||||
/// <see cref="HttpClient"/>.</param>
|
||||
/// <returns>The <see cref="HttpClient"/>.</returns>
|
||||
public HttpClient CreateClient(Uri baseAddress, params DelegatingHandler[] handlers)
|
||||
{
|
||||
if (handlers.Length == 0)
|
||||
if (handlers == null || handlers.Length == 0)
|
||||
{
|
||||
var client = _server.CreateClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
|
|
@ -117,6 +112,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Client.Dispose();
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// 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.
|
||||
|
||||
namespace FiltersWebSite
|
||||
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Information about an exception that occurred on the server side of a functional
|
||||
|
|
@ -4,10 +4,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using FiltersWebSite;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace FiltersWebSite
|
||||
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||
{
|
||||
public static class HttpResponseMessageExceptions
|
||||
{
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\build\common.props" />
|
||||
<Import Project="..\..\src\Microsoft.AspNetCore.Mvc.Testing\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Testing.targets" />
|
||||
<Import Project="..\..\src\Microsoft.AspNetCore.Mvc.Testing.Xunit\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Testing.Xunit.targets" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
|
|
@ -18,10 +17,11 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="..\Microsoft.AspNetCore.Mvc.Formatters.Xml.Test\XmlAssert.cs" />
|
||||
<EmbeddedResource Include="compiler\resources\**\*" />
|
||||
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Testing.Xunit\Microsoft.AspNetCore.Mvc.Testing.Xunit.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Testing\Microsoft.AspNetCore.Mvc.Testing.csproj" />
|
||||
<ProjectReference Include="..\WebSites\ApiExplorerWebSite\ApiExplorerWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\ApplicationModelWebSite\ApplicationModelWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\BasicWebSite\BasicWebSite.csproj" />
|
||||
|
|
@ -55,5 +55,4 @@
|
|||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -43,8 +43,6 @@ namespace ApiExplorerWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute("default", "{controller}/{action}");
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ namespace ApplicationModelWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ namespace BasicWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
// Initializes the RequestId service for each request
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ namespace BasicWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
app.UseSession();
|
||||
app.UseMvcWithDefaultRoute();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\ControllersFromServicesClassLibrary\ControllersFromServicesClassLibrary.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ namespace ControllersFromServicesWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute("default", "{controller}/{action}/{id}");
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -74,8 +74,6 @@ namespace CorsWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ namespace ErrorPageMiddlewareWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseMvc();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ namespace FilesWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(name: null, template: "{controller}/{action}", defaults: null);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Localization.Routing" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -60,8 +60,6 @@ namespace FiltersWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMiddleware<ErrorReporterMiddleware>();
|
||||
|
||||
app.UseMvcWithDefaultRoute();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ namespace FormatterWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute("ActionAsMethod", "{controller}/{action}",
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ namespace FormatterWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute("ActionAsMethod", "{controller}/{action}",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ namespace HtmlGenerationWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
app.UseStaticFiles();
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
// 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 Microsoft.AspNetCore.Mvc.TestConfiguration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Builder
|
||||
{
|
||||
public static class BuilderExtensions
|
||||
{
|
||||
// Should be added to the pipeline as early as possible.
|
||||
public static IApplicationBuilder UseCultureReplacer(this IApplicationBuilder app)
|
||||
{
|
||||
return app.UseMiddleware<CultureReplacerMiddleware>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ namespace RazorPageExecutionInstrumentationWebSite
|
|||
var diagnosticSource = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
|
||||
diagnosticSource.SubscribeWithAdapter(listener);
|
||||
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
using (var writer = new StreamWriter(context.Response.Body))
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ namespace RazorPagesWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ namespace RazorPagesWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ namespace RoutingWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapAreaRoute(
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ namespace TagHelpersWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvcWithDefaultRoute();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ namespace VersioningWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvcWithDefaultRoute();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ namespace WebApiCompatShimWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
// Tests include different styles of WebAPI conventional routing and action selection - the prefix keeps
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.WebApiCompatShim\Microsoft.AspNetCore.Mvc.WebApiCompatShim.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
|
|
@ -68,9 +68,6 @@ namespace XmlFormattersWebSite
|
|||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
// Add MVC to the request pipeline
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute("ActionAsMethod", "{controller}/{action}",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestConfiguration\Microsoft.AspNetCore.Mvc.TestConfiguration.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue