Cleanup TestCommon

This commit is contained in:
Pranav K 2018-05-09 21:56:17 -07:00
parent 624a5ed522
commit e1eaf6a6e0
No known key found for this signature in database
GPG Key ID: 1963DA6D96C3057A
137 changed files with 310 additions and 447 deletions

View File

@ -35,7 +35,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Ta
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.TagHelpers.Test", "test\Microsoft.AspNetCore.Mvc.TagHelpers.Test\Microsoft.AspNetCore.Mvc.TagHelpers.Test.csproj", "{860119ED-3DB1-424D-8D0A-30132A8A7D96}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.TestCommon", "test\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Core.TestCommon", "test\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.IntegrationTests", "test\Microsoft.AspNetCore.Mvc.IntegrationTests\Microsoft.AspNetCore.Mvc.IntegrationTests.csproj", "{864FA09D-1E48-403A-A6C8-4F079D2A30F0}"
EndProject
@ -112,6 +112,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.An
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Analyzers.Test", "test\Microsoft.AspNetCore.Mvc.Analyzers.Test\Microsoft.AspNetCore.Mvc.Analyzers.Test.csproj", "{829D9A67-2D07-4CE6-86C0-59F2549B0CFA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Views.TestCommon", "test\Microsoft.AspNetCore.Mvc.Views.TestCommon\Microsoft.AspNetCore.Mvc.Views.TestCommon.csproj", "{0772E545-A674-4165-9469-E3D79D88A4A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -546,6 +548,18 @@ Global
{829D9A67-2D07-4CE6-86C0-59F2549B0CFA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{829D9A67-2D07-4CE6-86C0-59F2549B0CFA}.Release|x86.ActiveCfg = Release|Any CPU
{829D9A67-2D07-4CE6-86C0-59F2549B0CFA}.Release|x86.Build.0 = Release|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Debug|x86.ActiveCfg = Debug|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Debug|x86.Build.0 = Debug|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Release|Any CPU.Build.0 = Release|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Release|x86.ActiveCfg = Release|Any CPU
{0772E545-A674-4165-9469-E3D79D88A4A8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -588,6 +602,7 @@ Global
{30862895-C1FA-49F5-B69A-B0F9F2ECD0F3} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
{F8FD2D6A-DCD1-4A7B-B599-B728A12A1754} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
{829D9A67-2D07-4CE6-86C0-59F2549B0CFA} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
{0772E545-A674-4165-9469-E3D79D88A4A8} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D003597F-372F-4068-A2F0-353BE3C3B39A}

17
Mvc.sln
View File

@ -75,7 +75,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControllersFromServicesWebS
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControllersFromServicesClassLibrary", "test\WebSites\ControllersFromServicesClassLibrary\ControllersFromServicesClassLibrary.csproj", "{551DC89E-2A13-4CF2-83D7-1ADD802443D5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.TestCommon", "test\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Core.TestCommon", "test\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CorsWebSite", "test\WebSites\CorsWebSite\CorsWebSite.csproj", "{94BA134D-04B3-48AA-BA55-5A4DB8640F2D}"
EndProject
@ -170,6 +170,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.An
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPagesClassLibrary", "test\WebSites\RazorPagesClassLibrary\RazorPagesClassLibrary.csproj", "{17122147-ADFD-41C8-87D9-CCC582CCA8F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Views.TestCommon", "test\Microsoft.AspNetCore.Mvc.Views.TestCommon\Microsoft.AspNetCore.Mvc.Views.TestCommon.csproj", "{51E3E785-A9D1-4196-BAFE-A17FF4304B89}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -892,6 +894,18 @@ Global
{17122147-ADFD-41C8-87D9-CCC582CCA8F9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{17122147-ADFD-41C8-87D9-CCC582CCA8F9}.Release|x86.ActiveCfg = Release|Any CPU
{17122147-ADFD-41C8-87D9-CCC582CCA8F9}.Release|x86.Build.0 = Release|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Debug|x86.ActiveCfg = Debug|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Debug|x86.Build.0 = Debug|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Release|Any CPU.Build.0 = Release|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Release|x86.ActiveCfg = Release|Any CPU
{51E3E785-A9D1-4196-BAFE-A17FF4304B89}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -961,6 +975,7 @@ Global
{CBF23034-2249-4FE5-BD48-5F3CEAC0DF61} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
{E83D3745-9BCF-40E8-8D34-AFBA604C2439} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
{17122147-ADFD-41C8-87D9-CCC582CCA8F9} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
{51E3E785-A9D1-4196-BAFE-A17FF4304B89} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {63D344F6-F86D-40E6-85B9-0AABBE338C4A}

View File

@ -6,7 +6,8 @@
</PropertyGroup>
<ItemGroup>
<ExcludeFromTest Include="$(RepositoryRoot)test\Microsoft.AspNetCore.Mvc.TestCommon\*.csproj" />
<ExcludeFromTest Include="$(RepositoryRoot)test\Microsoft.AspNetCore.Mvc.Core.TestCommon\*.csproj" />
<ExcludeFromTest Include="$(RepositoryRoot)test\Microsoft.AspNetCore.Mvc.Views.TestCommon\*.csproj" />
<ExcludeFromTest Include="$(RepositoryRoot)test\Microsoft.AspNetCore.Mvc.TestDiagnosticListener\*.csproj" />
<ExcludeSolutions Include="$(RepositoryRoot)Mvc.*Fun.sln" />
</ItemGroup>

View File

@ -4,7 +4,8 @@
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Mvc.Formatters;
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Core.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.TestCommon, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Core.TestCommon, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
[assembly: TypeForwardedTo(typeof(InputFormatterException))]

View File

@ -5,8 +5,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
</ItemGroup>

View File

@ -1744,7 +1744,7 @@ namespace Microsoft.AspNetCore.Mvc.Description
{
}
public class BaseProducesController : Controller
public class BaseProducesController : ControllerBase
{
public IActionResult ReturnsActionResult()
{

View File

@ -5,7 +5,9 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.ApiExplorer\Microsoft.AspNetCore.Mvc.ApiExplorer.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Json\Microsoft.AspNetCore.Mvc.Formatters.Json.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
</ItemGroup>
</Project>

View File

@ -454,49 +454,6 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
Assert.Equal(new[] { "ControllersAssembly", "MvcSandbox" }, candidates.Select(a => a.Name));
}
// This test verifies DefaultAssemblyPartDiscoveryProvider.ReferenceAssemblies reflects the actual loadable assemblies
// of the libraries that Microsoft.AspNetCore.Mvc depends on.
// If we add or remove dependencies, this test should be changed together.
[Fact]
public void ReferenceAssemblies_ReturnsLoadableReferenceAssemblies()
{
// Arrange
var excludeAssemblies = new string[]
{
"Microsoft.AspNetCore.Mvc.Core.Test",
"Microsoft.AspNetCore.Mvc.Razor.Extensions.Reference",
"Microsoft.AspNetCore.Mvc.TestCommon",
"Microsoft.AspNetCore.Mvc.TestDiagnosticListener",
"Microsoft.AspNetCore.Mvc.WebApiCompatShim",
};
var additionalAssemblies = new[]
{
// The following assemblies are not reachable from Microsoft.AspNetCore.Mvc
"Microsoft.AspNetCore.All",
"Microsoft.AspNetCore.Mvc.Formatters.Xml",
};
var dependencyContextLibraries = DependencyContext.Load(ThisAssembly)
.CompileLibraries
.Where(r => r.Name.StartsWith("Microsoft.AspNetCore.Mvc", StringComparison.OrdinalIgnoreCase) &&
!excludeAssemblies.Contains(r.Name, StringComparer.OrdinalIgnoreCase))
.Select(r => r.Name);
var expected = dependencyContextLibraries
.Concat(additionalAssemblies)
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
// Act
var referenceAssemblies = ApplicationAssembliesProvider
.ReferenceAssemblies
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
// Assert
Assert.Equal(expected, referenceAssemblies, StringComparer.OrdinalIgnoreCase);
}
private class TestApplicationAssembliesProvider : ApplicationAssembliesProvider
{
public DependencyContext DependencyContext { get; set; }

View File

@ -9,8 +9,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@ -259,7 +257,7 @@ namespace Microsoft.AspNetCore.Mvc
new ActionDescriptor());
}
private static IServiceCollection CreateServices(params ViewComponentDescriptor[] descriptors)
private static IServiceCollection CreateServices()
{
// An array pool could return a buffer which is greater or equal to the size of the default character
// chunk size. Since the tests here depend on a specific character buffer size to test boundary conditions,

View File

@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;

View File

@ -136,7 +136,7 @@ namespace Microsoft.AspNetCore.Mvc
// independent.
namespace Microsoft.AspNetCore.Mvc.MvcServiceCollectionExtensionsTestControllers
{
public class ControllerTypeA : Microsoft.AspNetCore.Mvc.Controller
public class ControllerTypeA : ControllerBase
{
}

View File

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

View File

@ -10,7 +10,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

View File

@ -7,9 +7,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Testing;
using Microsoft.Net.Http.Headers;
using Xunit;

View File

@ -2,18 +2,14 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
using Xunit;

View File

@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Internal
var valueTask = actionMethodExecutor.Execute(mapper, objectMethodExecutor, controller, Array.Empty<object>());
// Assert
Assert.IsType<PartialViewResult>(valueTask.Result);
Assert.IsType<ContentResult>(valueTask.Result);
}
[Fact]
@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Internal
var valueTask = actionMethodExecutor.Execute(mapper, objectMethodExecutor, controller, Array.Empty<object>());
// Assert
Assert.IsType<PartialViewResult>(valueTask.Result);
Assert.IsType<ContentResult>(valueTask.Result);
}
[Fact]
@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Internal
var valueTask = actionMethodExecutor.Execute(mapper, objectMethodExecutor, controller, Array.Empty<object>());
// Assert
Assert.IsType<ViewResult>(valueTask.Result);
Assert.IsType<StatusCodeResult>(valueTask.Result);
}
[Fact]
@ -183,7 +183,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Internal
// Assert
await valueTask;
Assert.IsType<ViewResult>(valueTask.Result);
Assert.IsType<StatusCodeResult>(valueTask.Result);
}
[Fact]
@ -291,7 +291,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Internal
public IActionResult ReturnIActionResult() => new ContentResult();
public PartialViewResult ReturnsIActionResultSubType() => new PartialViewResult();
public ContentResult ReturnsIActionResultSubType() => new ContentResult();
public ActionResult<TestModel> ReturnsActionResultOfT() => new ActionResult<TestModel>(new TestModel());
@ -309,9 +309,9 @@ namespace Microsoft.AspNetCore.Mvc.Core.Internal
return Task.CompletedTask;
}
public Task<IActionResult> ReturnIActionResultAsync() => Task.FromResult((IActionResult)new ViewResult());
public Task<IActionResult> ReturnIActionResultAsync() => Task.FromResult((IActionResult)new StatusCodeResult(201));
public Task<ViewResult> ReturnsIActionResultSubTypeAsync() => Task.FromResult(new ViewResult());
public Task<StatusCodeResult> ReturnsIActionResultSubTypeAsync() => Task.FromResult(new StatusCodeResult(200));
public Task<TestModel> ReturnsModelAsModelAsync() => Task.FromResult(new TestModel());

View File

@ -668,13 +668,13 @@ Environment.NewLine + "int b";
[ApiController]
[Route("TestApi")]
private class TestApiController : Controller
private class TestApiController : ControllerBase
{
[HttpGet]
public IActionResult TestAction() => null;
}
private class SimpleController : Controller
private class SimpleController : ControllerBase
{
public IActionResult ActionWithoutFilter() => null;

View File

@ -2024,7 +2024,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
}
}
private class UserController : Controller
private class UserController : ControllerBase
{
public string GetUser(int id)
{

View File

@ -1243,7 +1243,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
}
private class DerivedFromControllerAndExplicitIDisposableImplementationController
: Mvc.Controller, IDisposable
: ViewFeaturesController, IDisposable
{
void IDisposable.Dispose()
{
@ -1251,7 +1251,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
}
}
private class DerivedFromControllerAndHidesBaseDisposeMethodController : Mvc.Controller
private class DerivedFromControllerAndHidesBaseDisposeMethodController : ViewFeaturesController
{
public new void Dispose()
{
@ -1259,6 +1259,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal
}
}
private class ViewFeaturesController : ControllerBase, IDisposable
{
public virtual void Dispose()
{
}
}
private class BaseClassWithAttributeRoutesController
{
[Route("A")]

View File

@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Text;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.Net.Http.Headers;
using Xunit;
@ -107,14 +105,12 @@ namespace Microsoft.AspNetCore.Mvc.Internal
var defaultContentType = "text/default; p1=p1-value; charset=utf-8";
// Act
string resolvedContentType = null;
Encoding resolvedContentTypeEncoding = null;
ResponseContentTypeHelper.ResolveContentTypeAndEncoding(
contentType?.ToString(),
responseContentType,
defaultContentType,
out resolvedContentType,
out resolvedContentTypeEncoding);
out var resolvedContentType,
out var resolvedContentTypeEncoding);
// Assert
Assert.Equal(expectedContentType, resolvedContentType);
@ -128,14 +124,12 @@ namespace Microsoft.AspNetCore.Mvc.Internal
var defaultContentType = "text/plain; charset=utf-8";
// Act
string resolvedContentType = null;
Encoding resolvedContentTypeEncoding = null;
ResponseContentTypeHelper.ResolveContentTypeAndEncoding(
null,
expectedContentType,
defaultContentType,
out resolvedContentType,
out resolvedContentTypeEncoding);
out var resolvedContentType,
out var resolvedContentTypeEncoding);
// Assert
Assert.Equal(expectedContentType, resolvedContentType);

View File

@ -10,14 +10,12 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Json\Microsoft.AspNetCore.Mvc.Formatters.Json.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestDiagnosticListener\Microsoft.AspNetCore.Mvc.TestDiagnosticListener.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching" Version="$(MicrosoftAspNetCoreResponseCachingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(MicrosoftExtensionsLoggingTestingPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

View File

@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Formatters.Internal;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Primitives;
using Moq;

View File

@ -7,8 +7,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Testing;
@ -87,11 +85,11 @@ namespace Microsoft.AspNetCore.Mvc
RequestServices = CreateServices(),
};
var pageContext = new PageContext
var pageContext = new ActionContext
{
HttpContext = httpContext,
RouteData = new RouteData(),
ActionDescriptor = new CompiledPageActionDescriptor(),
ActionDescriptor = new ActionDescriptor(),
};
pageContext.RouteData.Values.Add("page", "/A/Redirecting/Page");
@ -144,7 +142,7 @@ namespace Microsoft.AspNetCore.Mvc
RequestServices = CreateServices(),
};
var pageContext = new PageContext
var pageContext = new ActionContext
{
HttpContext = httpContext,
RouteData = new RouteData(),

View File

@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;

View File

@ -5,7 +5,7 @@ using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
using Xunit.Sdk;
namespace Microsoft.AspNetCore.Mvc.TestCommon
namespace Microsoft.AspNetCore.Mvc
{
public class MediaTypeAssert
{
@ -35,11 +35,8 @@ namespace Microsoft.AspNetCore.Mvc.TestCommon
throw new EqualException(left.ToString(), right.ToString());
}
MediaTypeHeaderValue leftMediaType = null;
MediaTypeHeaderValue rightMediaType = null;
if (!MediaTypeHeaderValue.TryParse(left.Value, out leftMediaType) ||
!MediaTypeHeaderValue.TryParse(right.Value, out rightMediaType) ||
if (!MediaTypeHeaderValue.TryParse(left.Value, out var leftMediaType) ||
!MediaTypeHeaderValue.TryParse(right.Value, out var rightMediaType) ||
!leftMediaType.Equals(rightMediaType))
{
throw new EqualException(left.ToString(), right.ToString());

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Core\Microsoft.AspNetCore.Mvc.Core.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.DataAnnotations\Microsoft.AspNetCore.Mvc.DataAnnotations.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="$(MicrosoftExtensionsWebEncodersPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -6,7 +6,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Mvc.TestCommon
namespace Microsoft.AspNetCore.Mvc
{
public class NonSeekableReadStream : Stream
{

View File

@ -37,8 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
public ValueProviderResult GetValue(string key)
{
object rawValue;
if (TryGetValue(key, out rawValue))
if (TryGetValue(key, out var rawValue))
{
if (rawValue != null && rawValue.GetType().IsArray)
{

View File

@ -6,10 +6,8 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Cors\Microsoft.AspNetCore.Mvc.Cors.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Localization;
@ -26,16 +26,14 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var attribute = new CompareAttribute("OtherProperty");
var adapter = new CompareAttributeAdapter(attribute, stringLocalizer: null);
// Mono issue - https://github.com/aspnet/External/issues/19
var expectedMessage = PlatformNormalizer.NormalizeContent(
"'MyPropertyDisplayName' and 'OtherPropertyDisplayName' do not match.");
var expectedMessage = "'MyPropertyDisplayName' and 'OtherPropertyDisplayName' do not match.";
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(
actionContext,
metadata,
metadataProvider,
new AttributeDictionary());
new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -78,7 +76,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
actionContext,
metadata,
metadataProvider,
new AttributeDictionary());
new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -106,15 +104,14 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var attribute = new CompareAttribute("OtherProperty");
var adapter = new CompareAttributeAdapter(attribute, stringLocalizer: null);
// Mono issue - https://github.com/aspnet/External/issues/19
var expectedMessage = PlatformNormalizer.NormalizeContent("'MyProperty' and 'OtherProperty' do not match.");
var expectedMessage = "'MyProperty' and 'OtherProperty' do not match.";
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(
actionContext,
metadata,
metadataProvider,
new AttributeDictionary());
new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -151,7 +148,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
actionContext,
metadata,
metadataProvider,
new AttributeDictionary());
new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -191,7 +188,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
actionContext,
metadata,
metadataProvider,
new AttributeDictionary());
new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -224,7 +221,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
actionContext,
metadata,
metadataProvider,
new AttributeDictionary());
new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-equalto", "original");

View File

@ -1315,12 +1315,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
{
using (new CultureReplacer(string.Empty, string.Empty))
{
var hashcode = HashCodeCombiner.Start();
hashcode.Add(obj.Key.Name);
hashcode.Add(obj.Key.Group);
return hashcode.CombinedHash;
return obj.Key.GetHashCode();
}
}
}

View File

@ -1,9 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.DataAnnotations.Internal;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Localization;
using Moq;
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
var expectedErrorMessage = string.Format(attribute.ErrorMessage, nameof(Profile.PhotoFileName), formattedExtensions);
var adapter = new FileExtensionsAttributeAdapter(attribute, stringLocalizer: null);
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
var expectedErrorMessage = string.Format(attribute.ErrorMessage, nameof(Profile.PhotoFileName), formattedExtensions);
var adapter = new FileExtensionsAttributeAdapter(attribute, stringLocalizer: null);
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
.Returns(new LocalizedString(attribute.ErrorMessage, expectedErrorMessage));
var adapter = new FileExtensionsAttributeAdapter(attribute, stringLocalizer: stringLocalizer.Object);
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
attribute.ErrorMessage = "{0} expects only the following extensions: {1}";
var adapter = new FileExtensionsAttributeAdapter(attribute, stringLocalizer: null);
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(new ActionContext(), metadata, provider, new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-fileextensions", "original");

View File

@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Localization;
using Moq;
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new MaxLengthAttributeAdapter(attribute, stringLocalizer: stringLocalizer.Object);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = attribute.FormatErrorMessage("Length");
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new MaxLengthAttributeAdapter(attribute, stringLocalizer: null);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new MaxLengthAttributeAdapter(attribute, stringLocalizer.Object);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -151,7 +151,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = attribute.FormatErrorMessage("Length");
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-maxlength", "original");

View File

@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Localization;
using Moq;
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new MinLengthAttributeAdapter(attribute, stringLocalizer: stringLocalizer.Object);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = attribute.FormatErrorMessage("Length");
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = "Array must have at least 2 items.";
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new MinLengthAttributeAdapter(attribute, stringLocalizer: null);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-minlength", "original");

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
{
@ -34,11 +33,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
throw new ArgumentNullException(nameof(obj));
}
var hashCodeCombiner = HashCodeCombiner.Start();
hashCodeCombiner.Add(obj.MemberName, StringComparer.Ordinal);
hashCodeCombiner.Add(obj.Message, StringComparer.Ordinal);
return hashCodeCombiner.CombinedHash;
return obj.MemberName.GetHashCode();
}
}
}

View File

@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Xunit;
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new NumericClientModelValidator();
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
var expectedMessage = "The field DisplayId must be a number.";
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new NumericClientModelValidator();
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new NumericClientModelValidator();
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new NumericClientModelValidator();
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new NumericClientModelValidator();
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-number", "original");

View File

@ -1,9 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.DataAnnotations.Internal;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Localization;
using Moq;
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
var adapter = new RangeAttributeAdapter(attribute, stringLocalizer: null);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
var adapter = new RangeAttributeAdapter(attribute, stringLocalizer: stringLocalizer.Object);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
var adapter = new RangeAttributeAdapter(attribute, stringLocalizer: null);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-range", "original");

View File

@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Localization;
using Moq;
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new RequiredAttributeAdapter(attribute, stringLocalizer: stringLocalizer.Object);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new RequiredAttributeAdapter(attribute, stringLocalizer: null);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new RequiredAttributeAdapter(attribute, stringLocalizer: null);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-required", "original");

View File

@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Localization;
using Moq;
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var adapter = new StringLengthAttributeAdapter(attribute, stringLocalizer: stringLocalizer.Object);
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -47,7 +47,6 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
kvp => { Assert.Equal("data-val", kvp.Key); Assert.Equal("true", kvp.Value); },
kvp => { Assert.Equal("data-val-length", kvp.Key); Assert.Equal(expectedMessage, kvp.Value); },
kvp => { Assert.Equal("data-val-length-max", kvp.Key); Assert.Equal("8", kvp.Value); });
}
[Fact]
@ -64,7 +63,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = attribute.FormatErrorMessage("Length");
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -91,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = attribute.FormatErrorMessage("Length");
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -119,7 +118,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = attribute.FormatErrorMessage("Length");
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
// Act
adapter.AddValidation(context);
@ -145,7 +144,7 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
var expectedMessage = attribute.FormatErrorMessage("Length");
var actionContext = new ActionContext();
var context = new ClientModelValidationContext(actionContext, metadata, provider, new AttributeDictionary());
var context = new ClientModelValidationContext(actionContext, metadata, provider, new Dictionary<string, string>());
context.Attributes.Add("data-val", "original");
context.Attributes.Add("data-val-length", "original");

View File

@ -5,10 +5,8 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.HashCodeCombiner.Sources" PrivateAssets="All" Version="$(MicrosoftExtensionsHashCodeCombinerSourcesPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(MicrosoftExtensionsLoggingTestingPackageVersion)" />
</ItemGroup>

View File

@ -11,7 +11,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.ObjectPool;

View File

@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.ObjectPool;

View File

@ -5,11 +5,9 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Json\Microsoft.AspNetCore.Mvc.Formatters.Json.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -5,9 +5,8 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(MicrosoftExtensionsLoggingTestingPackageVersion)" />
</ItemGroup>

View File

@ -11,7 +11,6 @@ using System.Xml;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Moq;
using Xunit;

View File

@ -12,7 +12,6 @@ using System.Xml.Serialization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Moq;

View File

@ -7,6 +7,7 @@ using System.IO;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Mvc
@ -190,7 +191,8 @@ namespace Microsoft.AspNetCore.Mvc
{
// The build system compiles every file under the resources folder as a resource available at runtime
// with the same name as the file name. Need to update this file on disc.
var projectPath = SolutionPathUtility.GetProjectPath("test", assembly);
var solutionPath = TestPathUtilities.GetSolutionRootDirectory("Mvc");
var projectPath = Path.Combine(solutionPath, "test", assembly.GetName().Name);
var fullPath = Path.Combine(projectPath, resourceName);
WriteFile(fullPath, content);
}

View File

@ -91,12 +91,12 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
// Mono issue - https://github.com/aspnet/External/issues/29
Assert.Equal(PlatformNormalizer.NormalizeContent(
Assert.Equal(
"The field Id must be between 1 and 2000.," +
"The field Name must be a string or array type with a minimum length of '5'.," +
"The field Alias must be a string with a minimum length of 3 and a maximum length of 15.," +
"The field Designation must match the regular expression " +
(TestPlatformHelper.IsMono ? "[0-9a-zA-Z]*." : "'[0-9a-zA-Z]*'.")),
"'[0-9a-zA-Z]*'.",
await response.Content.ReadAsStringAsync());
}

View File

@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\src\Microsoft.AspNetCore.Mvc.Testing\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Testing.targets" />
<PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
<PlatformTarget Condition=" '$(TargetFramework)' == 'netcoreapp2.2' "></PlatformTarget>
<DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
<DefineConstants>$(DefineConstants);FUNCTIONAL_TESTS</DefineConstants>
</PropertyGroup>
<ItemGroup>
@ -26,6 +24,8 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Testing\Microsoft.AspNetCore.Mvc.Testing.csproj" />
<ProjectReference Include="..\..\samples\MvcSandbox\MvcSandbox.csproj" />
<ProjectReference Include="..\WebSites\ApiExplorerWebSite\ApiExplorerWebSite.csproj" />
<ProjectReference Include="..\WebSites\ApplicationModelWebSite\ApplicationModelWebSite.csproj" />
<ProjectReference Include="..\WebSites\BasicWebSite\BasicWebSite.csproj" />
@ -35,8 +35,6 @@
<ProjectReference Include="..\WebSites\FilesWebSite\FilesWebSite.csproj" />
<ProjectReference Include="..\WebSites\FormatterWebSite\FormatterWebSite.csproj" />
<ProjectReference Include="..\WebSites\HtmlGenerationWebSite\HtmlGenerationWebSite.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\..\samples\MvcSandbox\MvcSandbox.csproj" />
<ProjectReference Include="..\WebSites\RazorBuildWebSite\RazorBuildWebSite.csproj" />
<ProjectReference Include="..\WebSites\RazorPageExecutionInstrumentationWebSite\RazorPageExecutionInstrumentationWebSite.csproj" />
<ProjectReference Include="..\WebSites\RazorPagesWebSite\RazorPagesWebSite.csproj" />
@ -51,10 +49,7 @@
<PackageReference Include="AngleSharp" Version="$(AngleSharpPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.ChunkingCookieManager.Sources" PrivateAssets="All" Version="$(MicrosoftAspNetCoreChunkingCookieManagerSourcesPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(MicrosoftAspNetCoreTestHostPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="$(MicrosoftAspNetCoreWebUtilitiesPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsConfigurationJsonPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(MicrosoftExtensionsLoggingTestingPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -45,9 +45,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
#if GENERATE_BASELINES
ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
#else
// Mono issue - https://github.com/aspnet/External/issues/19
Assert.Equal(
PlatformNormalizer.NormalizeContent(expectedContent),
expectedContent,
responseContent,
ignoreLineEndingDifferences: true);
#endif

View File

@ -116,9 +116,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
#else
expectedContent = string.Format(expectedContent, forgeryToken);
// Mono issue - https://github.com/aspnet/External/issues/19
Assert.Equal(
PlatformNormalizer.NormalizeContent(expectedContent.Trim()),
expectedContent.Trim(),
responseContent,
ignoreLineEndingDifferences: true);
#endif
@ -217,9 +216,8 @@ page:<root>root-content</root>"
#if GENERATE_BASELINES
ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
#else
// Mono issue - https://github.com/aspnet/External/issues/19
Assert.Equal(
PlatformNormalizer.NormalizeContent(expectedContent),
expectedContent,
responseContent,
ignoreLineEndingDifferences: true);
#endif
@ -285,9 +283,8 @@ page:<root>root-content</root>"
#if GENERATE_BASELINES
ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
#else
// Mono issue - https://github.com/aspnet/External/issues/19
Assert.Equal(
PlatformNormalizer.NormalizeContent(expectedContent),
expectedContent,
responseContent,
ignoreLineEndingDifferences: true);
#endif

View File

@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Options;
using Xunit;
@ -78,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests
serviceCollection.AddAuthorization();
serviceCollection.AddMvc();
serviceCollection
.AddTransient<ILoggerFactory, LoggerFactory>()
.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance)
.AddTransient<ILogger<DefaultAuthorizationService>, Logger<DefaultAuthorizationService>>()
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
return serviceCollection.BuildServiceProvider();

View File

@ -6,9 +6,8 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPackageVersion)" />
</ItemGroup>

View File

@ -189,7 +189,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
serviceCollection
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()
.AddTransient<ILoggerFactory, LoggerFactory>()
.AddSingleton<ILoggerFactory>(NullLoggerFactory.Instance)
.AddTransient<ILogger<DefaultAuthorizationService>, Logger<DefaultAuthorizationService>>();
if (updateOptions != null)

View File

@ -5,10 +5,8 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Localization\Microsoft.AspNetCore.Mvc.Localization.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
</ItemGroup>
</Project>

View File

@ -1,13 +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.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.Razor.Internal;
using Microsoft.AspNetCore.Mvc.Razor.TagHelpers;
using Microsoft.AspNetCore.Razor.Runtime.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
@ -21,12 +19,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Test.DependencyInjection
{
// Arrange
var services = new ServiceCollection();
var builder = services
.AddMvc()
.ConfigureApplicationPartManager(manager =>
{
manager.ApplicationParts.Add(new TestApplicationPart());
});
var manager = new ApplicationPartManager();
manager.ApplicationParts.Add(new TestApplicationPart());
var builder = new MvcBuilder(services, manager);
// Act
builder.AddTagHelpersAsServices();

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
typeof(TestModel),
new TestModelMetadataProvider(),
new EmptyModelMetadataProvider(),
propertyValueAccessors: null);
var viewContext = new ViewContext();
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
declaredModelType: null,
metadataProvider: new TestModelMetadataProvider(),
metadataProvider: new EmptyModelMetadataProvider(),
propertyValueAccessors: null);
var viewContext = new ViewContext();
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
public void CreateViewDataDictionary_CreatesNestedViewDataDictionary_WhenContextInstanceIsNonGeneric()
{
// Arrange
var modelMetadataProvider = new TestModelMetadataProvider();
var modelMetadataProvider = new EmptyModelMetadataProvider();
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
declaredModelType: typeof(TestModel),
@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
public void CreateViewDataDictionary_UsesDeclaredTypeOverModelType_WhenCreatingTheViewDataDictionary()
{
// Arrange
var modelMetadataProvider = new TestModelMetadataProvider();
var modelMetadataProvider = new EmptyModelMetadataProvider();
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
declaredModelType: typeof(TestModel),
@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
public void CreateViewDataDictionary_CreatesNestedViewDataDictionary_WhenModelTypeDoesNotMatch()
{
// Arrange
var modelMetadataProvider = new TestModelMetadataProvider();
var modelMetadataProvider = new EmptyModelMetadataProvider();
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
declaredModelType: typeof(TestModel),
@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
public void CreateViewDataDictionary_CreatesNestedViewDataDictionary_WhenNullModelTypeDoesNotMatch()
{
// Arrange
var modelMetadataProvider = new TestModelMetadataProvider();
var modelMetadataProvider = new EmptyModelMetadataProvider();
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
declaredModelType: null,
@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
public void CreateViewDataDictionary_ReturnsInstanceOnContext_IfModelTypeMatches()
{
// Arrange
var modelMetadataProvider = new TestModelMetadataProvider();
var modelMetadataProvider = new EmptyModelMetadataProvider();
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
declaredModelType: typeof(TestModel),
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
public void CreateViewDataDictionary_ReturnsInstanceOnContext_WithNullModelType()
{
// Arrange
var modelMetadataProvider = new TestModelMetadataProvider();
var modelMetadataProvider = new EmptyModelMetadataProvider();
var activator = new RazorPagePropertyActivator(
typeof(TestPage),
declaredModelType: null,

View File

@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Moq;

View File

@ -11,13 +11,11 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor\Microsoft.AspNetCore.Mvc.Razor.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Views.TestCommon\Microsoft.AspNetCore.Mvc.Views.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestDiagnosticListener\Microsoft.AspNetCore.Mvc.TestDiagnosticListener.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources" PrivateAssets="All" Version="$(MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(MicrosoftExtensionsLoggingTestingPackageVersion)" />
</ItemGroup>

View File

@ -209,7 +209,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
private static IModelExpressionProvider CreateModelExpressionProvider()
{
var provider = new TestModelMetadataProvider();
var provider = new EmptyModelMetadataProvider();
var modelExpressionProvider = new ModelExpressionProvider(
provider,
new ExpressionTextCache());
@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
private static ViewContext CreateViewContext()
{
var provider = new TestModelMetadataProvider();
var provider = new EmptyModelMetadataProvider();
var viewData = new ViewDataDictionary<RazorPageCreateModelExpressionModel>(provider, new ModelStateDictionary());
var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton<IModelMetadataProvider>(provider);

View File

@ -14,7 +14,6 @@ using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;

View File

@ -6,6 +6,7 @@ using System.Linq;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using Xunit;
@ -94,4 +95,4 @@ namespace Microsoft.AspNetCore.Mvc.Razor
Assert.Same(fileProvider, accessor.Value.FileProviders[0]);
}
}
}
}

View File

@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Options;

View File

@ -7,9 +7,7 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.WebEncoders.Testing;
using Moq;

View File

@ -15,12 +15,12 @@ using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Razor.Compilation;
using Microsoft.AspNetCore.Mvc.Razor.Internal;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Moq;

View File

@ -6,12 +6,10 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.RazorPages\Microsoft.AspNetCore.Mvc.RazorPages.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Views.TestCommon\Microsoft.AspNetCore.Mvc.Views.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestDiagnosticListener\Microsoft.AspNetCore.Mvc.TestDiagnosticListener.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(MicrosoftExtensionsLoggingTestingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="$(MicrosoftExtensionsDiagnosticAdapterPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Testing;

View File

@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
using Microsoft.AspNetCore.Routing;

View File

@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;

View File

@ -9,7 +9,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers;

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Xunit;

View File

@ -12,11 +12,9 @@ using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;

View File

@ -6,12 +6,9 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.TagHelpers\Microsoft.AspNetCore.Mvc.TagHelpers.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.TestCommon\Microsoft.AspNetCore.Mvc.TestCommon.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Views.TestCommon\Microsoft.AspNetCore.Mvc.Views.TestCommon.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="$(MicrosoftAspNetCoreHttpPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.TagHelpers.Testing.Sources" PrivateAssets="All" Version="$(MicrosoftAspNetCoreRazorTagHelpersTestingSourcesPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;

View File

@ -12,11 +12,9 @@ using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;

View File

@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Testing;

View File

@ -5,13 +5,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers.Testing;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.WebEncoders.Testing;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Xunit;
namespace Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.AspNetCore.Testing;

View File

@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;

View File

@ -0,0 +1,56 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyModel;
using Xunit;
namespace Microsoft.AspNetCore.Mvc.ApplicationParts
{
public class ApplicationAssembliesProviderTest
{
private static readonly Assembly ThisAssembly = typeof(ApplicationAssembliesProviderTest).Assembly;
// This test verifies ApplicationAssembliesProviderTest.ReferenceAssemblies reflects the actual loadable assemblies
// of the libraries that Microsoft.AspNetCore.Mvc depends on.
// If we add or remove dependencies, this test should be changed together.
[Fact]
public void ReferenceAssemblies_ReturnsLoadableReferenceAssemblies()
{
// Arrange
var excludeAssemblies = new string[]
{
"Microsoft.AspNetCore.Mvc.Test",
"Microsoft.AspNetCore.Mvc.Core.TestCommon",
};
var additionalAssemblies = new[]
{
// The following assemblies are not reachable from Microsoft.AspNetCore.Mvc
"Microsoft.AspNetCore.All",
"Microsoft.AspNetCore.Mvc.Formatters.Xml",
};
var dependencyContextLibraries = DependencyContext.Load(ThisAssembly)
.CompileLibraries
.Where(r => r.Name.StartsWith("Microsoft.AspNetCore.Mvc", StringComparison.OrdinalIgnoreCase) &&
!excludeAssemblies.Contains(r.Name, StringComparer.OrdinalIgnoreCase))
.Select(r => r.Name);
var expected = dependencyContextLibraries
.Concat(additionalAssemblies)
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
// Act
var referenceAssemblies = ApplicationAssembliesProvider
.ReferenceAssemblies
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
// Assert
Assert.Equal(expected, referenceAssemblies, StringComparer.OrdinalIgnoreCase);
}
}
}

View File

@ -2,14 +2,17 @@
<PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<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" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(MicrosoftExtensionsConfigurationPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
{
"shadowCopy": false
}

View File

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Formatters.Xml\Microsoft.AspNetCore.Mvc.Formatters.Xml.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.ViewFeatures\Microsoft.AspNetCore.Mvc.ViewFeatures.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="$(MicrosoftAspNetCoreHtmlAbstractionsPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="$(MicrosoftAspNetCoreRazorRuntimePackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="$(MicrosoftAspNetCoreRazorLanguagePackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="$(MicrosoftExtensionsFileProvidersAbstractionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Options" Version="$(MicrosoftExtensionsOptionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="$(MicrosoftExtensionsWebEncodersPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -1,44 +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.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Testing;
namespace Microsoft.AspNetCore.Mvc
{
public static class PlatformNormalizer
{
// Mono issue - https://github.com/aspnet/External/issues/19
public static string NormalizeContent(string input)
{
if (TestPlatformHelper.IsMono)
{
var equivalents = new Dictionary<string, string> {
{
"The [0-9a-zA-Z ]+ field is required.", "RequiredAttribute_ValidationError"
},
{
"'[0-9a-zA-Z ]+' and '[0-9a-zA-Z ]+' do not match.", "CompareAttribute_MustMatch"
},
{
"The field [0-9a-zA-Z ]+ must be a string with a minimum length of [0-9]+ and a " +
"maximum length of [0-9]+.",
"StringLengthAttribute_ValidationErrorIncludingMinimum"
},
};
var result = input;
foreach (var kvp in equivalents)
{
result = Regex.Replace(result, kvp.Key, kvp.Value);
}
return result;
}
return input;
}
}
}

View File

@ -1,44 +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.IO;
using System.Reflection;
namespace Microsoft.AspNetCore.Mvc
{
public static class SolutionPathUtility
{
private const string SolutionName = "Mvc.sln";
/// <summary>
/// Gets the full path to the project.
/// </summary>
/// <param name="solutionRelativePath">
/// The parent directory of the project.
/// e.g. samples, test, or test/Websites
/// </param>
/// <param name="assembly">The project's assembly.</param>
/// <returns>The full path to the project.</returns>
public static string GetProjectPath(string solutionRelativePath, Assembly assembly)
{
var projectName = assembly.GetName().Name;
var applicationBasePath = AppContext.BaseDirectory;
var directoryInfo = new DirectoryInfo(applicationBasePath);
do
{
var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, SolutionName));
if (solutionFileInfo.Exists)
{
return Path.GetFullPath(Path.Combine(directoryInfo.FullName, solutionRelativePath, projectName));
}
directoryInfo = directoryInfo.Parent;
}
while (directoryInfo.Parent != null);
throw new Exception($"Solution root could not be located using application root {applicationBasePath}.");
}
}
}

View File

@ -20,20 +20,20 @@ namespace Microsoft.Extensions.DependencyInjection
public void AddViewComponentsAsServices_ReplacesViewComponentActivator()
{
// Arrange
var services = new ServiceCollection();
var builder = services
.AddMvc()
.ConfigureApplicationPartManager(manager =>
{
manager.ApplicationParts.Add(new TestApplicationPart());
manager.FeatureProviders.Add(new ViewComponentFeatureProvider());
});
var builder = CreateBuilder();
MvcViewFeaturesMvcCoreBuilderExtensions.AddViewServices(builder.Services);
builder.ConfigureApplicationPartManager(manager =>
{
manager.ApplicationParts.Add(new TestApplicationPart());
manager.FeatureProviders.Add(new ViewComponentFeatureProvider());
});
// Act
builder.AddViewComponentsAsServices();
// Assert
var descriptor = Assert.Single(services.ToList(), d => d.ServiceType == typeof(IViewComponentActivator));
var descriptor = Assert.Single(builder.Services.ToList(), d => d.ServiceType == typeof(IViewComponentActivator));
Assert.Equal(typeof(ServiceBasedViewComponentActivator), descriptor.ImplementationType);
}
@ -41,14 +41,13 @@ namespace Microsoft.Extensions.DependencyInjection
public void AddCookieTempDataProvider_RegistersExpectedTempDataProvider()
{
// Arrange
var services = new ServiceCollection();
var builder = services.AddMvc();
var builder = CreateBuilder();
// Act
builder.AddCookieTempDataProvider();
// Assert
var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider));
var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider));
Assert.Equal(typeof(CookieTempDataProvider), descriptor.ImplementationType);
}
@ -56,15 +55,14 @@ namespace Microsoft.Extensions.DependencyInjection
public void AddCookieTempDataProvider_DoesNotRegisterOptionsConfiguration()
{
// Arrange
var services = new ServiceCollection();
var builder = services.AddMvc();
var builder = CreateBuilder();
// Act
builder.AddCookieTempDataProvider();
// Assert
Assert.DoesNotContain(
services,
builder.Services,
item => item.ServiceType == typeof(IConfigureOptions<CookieTempDataProviderOptions>));
}
@ -72,14 +70,13 @@ namespace Microsoft.Extensions.DependencyInjection
public void AddCookieTempDataProviderWithSetupAction_RegistersExpectedTempDataProvider()
{
// Arrange
var services = new ServiceCollection();
var builder = services.AddMvc();
var builder = CreateBuilder();
// Act
builder.AddCookieTempDataProvider(options => { });
// Assert
var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider));
var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider));
Assert.Equal(typeof(CookieTempDataProvider), descriptor.ImplementationType);
}
@ -87,15 +84,14 @@ namespace Microsoft.Extensions.DependencyInjection
public void AddCookieTempDataProviderWithSetupAction_RegistersOptionsConfiguration()
{
// Arrange
var services = new ServiceCollection();
var builder = services.AddMvc();
var builder = CreateBuilder();
// Act
builder.AddCookieTempDataProvider(options => { });
// Assert
Assert.Single(
services,
builder.Services,
item => item.ServiceType == typeof(IConfigureOptions<CookieTempDataProviderOptions>));
}
@ -103,15 +99,14 @@ namespace Microsoft.Extensions.DependencyInjection
public void AddCookieTempDataProvider_RegistersExpectedTempDataProvider_IfCalledTwice()
{
// Arrange
var services = new ServiceCollection();
var builder = services.AddMvc();
var builder = CreateBuilder();
// Act
builder.AddCookieTempDataProvider();
builder.AddCookieTempDataProvider();
// Assert
var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider));
var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider));
Assert.Equal(typeof(CookieTempDataProvider), descriptor.ImplementationType);
}
@ -119,15 +114,14 @@ namespace Microsoft.Extensions.DependencyInjection
public void AddCookieTempDataProviderWithSetupAction_RegistersExpectedTempDataProvider_IfCalledTwice()
{
// Arrange
var services = new ServiceCollection();
var builder = services.AddMvc();
var builder = CreateBuilder();
// Act
builder.AddCookieTempDataProvider(options => { });
builder.AddCookieTempDataProvider(options => { });
// Assert
var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider));
var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider));
Assert.Equal(typeof(CookieTempDataProvider), descriptor.ImplementationType);
}
@ -166,6 +160,14 @@ namespace Microsoft.Extensions.DependencyInjection
Assert.Equal(ServiceLifetime.Singleton, collection[2].Lifetime);
}
private static MvcBuilder CreateBuilder()
{
var services = new ServiceCollection();
var manager = new ApplicationPartManager();
var builder = new MvcBuilder(services, manager);
return builder;
}
public class ConventionsViewComponent
{
public string Invoke() => "Hello world";

View File

@ -10,7 +10,6 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Moq;
using Xunit;

View File

@ -14,7 +14,6 @@ using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.TestCommon;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Testing;
using Moq;

Some files were not shown because too many files have changed in this diff Show More