Workaround for issue https://github.com/aspnet/Routing/issues/390
This commit is contained in:
parent
569a4e3d13
commit
2388cca5ac
|
|
@ -31,7 +31,9 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{6DC6B416-C8C4-4BFA-8C1E-A55A6D7EFD08}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
build\common.props = build\common.props
|
||||
build\dependencies.props = build\dependencies.props
|
||||
build\Key.snk = build\Key.snk
|
||||
build\repo.props = build\repo.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Routing.Performance", "test\Microsoft.AspNetCore.Routing.Performance\Microsoft.AspNetCore.Routing.Performance.csproj", "{F3D86714-4E64-41A6-9B36-A47B3683CF5D}"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<BenchmarkDotNetVersion>0.10.3</BenchmarkDotNetVersion>
|
||||
<CoreFxVersion>4.3.0</CoreFxVersion>
|
||||
<InternalAspNetCoreSdkVersion>2.0.0-*</InternalAspNetCoreSdkVersion>
|
||||
<MoqVersion>4.6.36-alpha</MoqVersion>
|
||||
<MoqVersion>4.7.1</MoqVersion>
|
||||
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
|
||||
<RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion>
|
||||
<TestSdkVersion>15.0.0</TestSdkVersion>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
{
|
||||
// Act
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var result = constraint.Match(
|
||||
Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
Mock.Of<IRouter>(),
|
||||
"area",
|
||||
new RouteValueDictionary(new { controller = "Home", action = "Index" }),
|
||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var result = constraint.Match(
|
||||
Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
Mock.Of<IRouter>(),
|
||||
"area",
|
||||
new RouteValueDictionary(new { controller = "Home", action = "Index", area = (string)null }),
|
||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var result = constraint.Match(
|
||||
Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
Mock.Of<IRouter>(),
|
||||
"area",
|
||||
new RouteValueDictionary(new { controller = "Home", action = "Index", area = string.Empty}),
|
||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Routing.Tests
|
|||
|
||||
// Act
|
||||
var result = constraint.Match(
|
||||
Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
Mock.Of<IRouter>(),
|
||||
"area",
|
||||
new RouteValueDictionary(new { controller = "Home", action = "Index", area = "Store" }),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
|
|||
var values = new RouteValueDictionary(new { controller = "home" });
|
||||
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
|
|||
var values = new RouteValueDictionary(new { controller = "home" });
|
||||
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
|
|||
var values = new RouteValueDictionary(new { controller = "home" });
|
||||
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
|
|||
var values = new RouteValueDictionary(new { controller = "home" });
|
||||
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
|
|||
var values = new RouteValueDictionary(new { controller = "admin" });
|
||||
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "action",
|
||||
values: values,
|
||||
|
|
@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
|
|||
var values = new RouteValueDictionary(new { controller = "admin" });
|
||||
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "action",
|
||||
values: values,
|
||||
|
|
@ -144,7 +144,7 @@ namespace Microsoft.AspNetCore.Routing.Constraints
|
|||
var values = new RouteValueDictionary(new { controller = routeValue });
|
||||
|
||||
var match = constraint.Match(
|
||||
httpContext: Mock.Of<HttpContext>(),
|
||||
new DefaultHttpContext(),
|
||||
route: new Mock<IRouter>().Object,
|
||||
routeKey: "controller",
|
||||
values: values,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -14,6 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Routing
|
|||
Assert.NotNull(exception.InnerException);
|
||||
expected = "The constraint entry 'p1' - 'regex(abc' on the route " +
|
||||
"'{controller}/{action}/ {p1:regex(abc} ' could not be resolved by the constraint resolver of type " +
|
||||
"'IInlineConstraintResolverProxy'.";
|
||||
$"'{nameof(DefaultInlineConstraintResolver)}'.";
|
||||
Assert.Equal(expected, exception.InnerException.Message);
|
||||
}
|
||||
|
||||
|
|
@ -1704,15 +1704,12 @@ namespace Microsoft.AspNetCore.Routing
|
|||
|
||||
private static IInlineConstraintResolver GetInlineConstraintResolver()
|
||||
{
|
||||
var resolverMock = new Mock<IInlineConstraintResolver>();
|
||||
resolverMock.Setup(o => o.ResolveConstraint("int")).Returns(new IntRouteConstraint());
|
||||
resolverMock.Setup(o => o.ResolveConstraint("range(1,20)")).Returns(new RangeRouteConstraint(1, 20));
|
||||
resolverMock.Setup(o => o.ResolveConstraint("alpha")).Returns(new AlphaRouteConstraint());
|
||||
resolverMock.Setup(o => o.ResolveConstraint(@"regex(^\d{3}-\d{3}-\d{4}$)")).Returns(
|
||||
new RegexInlineRouteConstraint(@"^\d{3}-\d{3}-\d{4}$"));
|
||||
resolverMock.Setup(o => o.ResolveConstraint(@"regex(^\d{1,2}\/\d{1,2}\/\d{4}$)")).Returns(
|
||||
new RegexInlineRouteConstraint(@"^\d{1,2}\/\d{1,2}\/\d{4}$"));
|
||||
return resolverMock.Object;
|
||||
var routeOptions = new Mock<IOptions<RouteOptions>>();
|
||||
routeOptions
|
||||
.SetupGet(o => o.Value)
|
||||
.Returns(new RouteOptions());
|
||||
|
||||
return new DefaultInlineConstraintResolver(routeOptions.Object);
|
||||
}
|
||||
|
||||
private class CapturingConstraint : IRouteConstraint
|
||||
|
|
@ -1730,5 +1727,10 @@ namespace Microsoft.AspNetCore.Routing
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class TestRouteOptions : IOptions<RouteOptions>
|
||||
{
|
||||
public RouteOptions Value => new RouteOptions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue