diff --git a/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs index 87e950c046..49256d7778 100644 --- a/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Routing; using Microsoft.Framework.ConfigurationModel; namespace Microsoft.Framework.DependencyInjection @@ -10,11 +11,13 @@ namespace Microsoft.Framework.DependencyInjection { public static IServiceCollection AddMvc(this IServiceCollection services) { + services.Add(RoutingServices.GetDefaultServices()); return services.Add(MvcServices.GetDefaultServices()); } public static IServiceCollection AddMvc(this IServiceCollection services, IConfiguration configuration) { + services.Add(RoutingServices.GetDefaultServices()); return services.Add(MvcServices.GetDefaultServices(configuration)); } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs index 2ef66f03f8..ca94626f6e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using Microsoft.AspNet.Http; using Microsoft.AspNet.Routing; using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.OptionsModel; using Moq; using Xunit; @@ -535,8 +536,12 @@ namespace Microsoft.AspNet.Mvc.Core.Test .Returns(rc => null); rt.DefaultHandler = target.Object; var serviceProviderMock = new Mock(); + var accessorMock = new Mock>(); + accessorMock.SetupGet(o => o.Options).Returns(new RouteOptions()); serviceProviderMock.Setup(o => o.GetService(typeof(IInlineConstraintResolver))) - .Returns(new DefaultInlineConstraintResolver()); + .Returns(new DefaultInlineConstraintResolver(serviceProviderMock.Object, + accessorMock.Object)); + rt.ServiceProvider = serviceProviderMock.Object; rt.MapRoute(string.Empty, "{controller}/{action}/{id}",