React to hosting changes

This commit is contained in:
Hao Kung 2015-03-19 11:07:25 -07:00
parent 015edefa96
commit 4b5dd199ca
127 changed files with 1611 additions and 1334 deletions

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System; using System;
#if DNX451
using System.IO; using System.IO;
using Autofac; using Autofac;
#endif #endif
@ -16,97 +16,91 @@ using Microsoft.Framework.DependencyInjection;
#if DNX451 #if DNX451
using Microsoft.Framework.DependencyInjection.Autofac; using Microsoft.Framework.DependencyInjection.Autofac;
using Microsoft.Framework.Runtime; using Microsoft.Framework.Runtime;
using Microsoft.Framework.Runtime.Infrastructure;
#endif #endif
using MvcSample.Web.Filters; using MvcSample.Web.Filters;
using MvcSample.Web.Services; using MvcSample.Web.Services;
namespace MvcSample.Web namespace MvcSample.Web
{ {
public class Startup public class Startup
{ {
public void Configure(IApplicationBuilder app) #if DNX451
private bool _autoFac;
#endif
public IServiceProvider ConfigureServices(IServiceCollection services)
{ {
app.UseStatusCodePages(); services.AddCaching();
app.UseFileServer(); services.AddSession();
services.AddMvc();
services.AddSingleton<PassThroughAttribute>();
services.AddSingleton<UserNameService>();
services.AddTransient<ITestService, TestService>();
services.ConfigureMvc(options =>
{
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
options.AddXmlDataContractSerializerFormatter();
options.Filters.Add(new FormatFilterAttribute());
});
#if DNX451 #if DNX451
// Fully-qualify configuration path to avoid issues in functional tests. Just "config.json" would be fine // Fully-qualify configuration path to avoid issues in functional tests. Just "config.json" would be fine
// but Configuration uses CallContextServiceLocator.Locator.ServiceProvider to get IApplicationEnvironment. // but Configuration uses CallContextServiceLocator.Locator.ServiceProvider to get IApplicationEnvironment.
// Functional tests update that service but not in the static provider. // Functional tests update that service but not in the static provider.
var applicationEnvironment = app.ApplicationServices.GetRequiredService<IApplicationEnvironment>(); var applicationEnvironment = services.BuildServiceProvider().GetRequiredService<IApplicationEnvironment>();
var configurationPath = Path.Combine(applicationEnvironment.ApplicationBasePath, "config.json"); var configurationPath = Path.Combine(applicationEnvironment.ApplicationBasePath, "config.json");
// Set up configuration sources. // Set up configuration sources.
var configuration = new Configuration() var configuration = new Configuration()
.AddJsonFile(configurationPath) .AddJsonFile(configurationPath)
.AddEnvironmentVariables(); .AddEnvironmentVariables();
string diSystem; string diSystem;
if (configuration.TryGet("DependencyInjection", out diSystem) && if (configuration.TryGet("DependencyInjection", out diSystem) &&
diSystem.Equals("AutoFac", StringComparison.OrdinalIgnoreCase)) diSystem.Equals("AutoFac", StringComparison.OrdinalIgnoreCase))
{ {
app.UseMiddleware<MonitoringMiddlware>(); _autoFac = true;
services.ConfigureRazorViewEngine(options =>
app.UseServices(services =>
{ {
services.AddCaching(); var expander = new LanguageViewLocationExpander(
services.AddSession(); context => context.HttpContext.Request.Query["language"]);
options.ViewLocationExpanders.Insert(0, expander);
services.AddMvc();
services.AddSingleton<PassThroughAttribute>();
services.AddSingleton<UserNameService>();
services.AddTransient<ITestService, TestService>();
services.ConfigureMvc(options =>
{
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
options.AddXmlDataContractSerializerFormatter();
options.Filters.Add(new FormatFilterAttribute());
});
services.ConfigureRazorViewEngine(options =>
{
var expander = new LanguageViewLocationExpander(
context => context.HttpContext.Request.Query["language"]);
options.ViewLocationExpanders.Insert(0, expander);
});
// Create the autofac container
ContainerBuilder builder = new ContainerBuilder();
// Create the container and use the default application services as a fallback
AutofacRegistration.Populate(
builder,
services);
builder.RegisterModule<MonitoringModule>();
IContainer container = builder.Build();
return container.Resolve<IServiceProvider>();
}); });
// Create the autofac container
var builder = new ContainerBuilder();
// Create the container and use the default application services as a fallback
AutofacRegistration.Populate(
builder,
services);
builder.RegisterModule<MonitoringModule>();
var container = builder.Build();
return container.Resolve<IServiceProvider>();
} }
else else
#endif #endif
{ {
app.UseServices(services => return services.BuildServiceProvider();
{
services.AddCaching();
services.AddSession();
services.AddMvc();
services.AddSingleton<PassThroughAttribute>();
services.AddSingleton<UserNameService>();
services.AddTransient<ITestService, TestService>();
services.ConfigureMvc(options =>
{
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
options.AddXmlDataContractSerializerFormatter();
options.Filters.Add(new FormatFilterAttribute());
});
});
} }
}
public void Configure(IApplicationBuilder app)
{
app.UseStatusCodePages();
app.UseFileServer();
#if DNX451
if (_autoFac)
{
app.UseMiddleware<MonitoringMiddlware>();
}
#endif
app.UseInMemorySession(); app.UseInMemorySession();
app.UseMvc(routes => app.UseMvc(routes =>

View File

@ -11,15 +11,16 @@ namespace TagHelperSample.Web
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton<MoviesService>();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{ {
app.UseServices(services =>
{
services.AddMvc();
services.AddSingleton<MoviesService>();
});
loggerFactory.AddConsole((name, logLevel) => loggerFactory.AddConsole((name, logLevel) =>
name.StartsWith("Microsoft.AspNet.Mvc.TagHelpers", StringComparison.OrdinalIgnoreCase) name.StartsWith("Microsoft.AspNet.Mvc.TagHelpers", StringComparison.OrdinalIgnoreCase)
|| (name.StartsWith("Microsoft.Net.Http.Server.WebListener", StringComparison.OrdinalIgnoreCase) || (name.StartsWith("Microsoft.Net.Http.Server.WebListener", StringComparison.OrdinalIgnoreCase)

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.Internal
{ {
throw new InvalidOperationException(Resources.FormatUnableToFindServices( throw new InvalidOperationException(Resources.FormatUnableToFindServices(
"IServiceCollection.AddMvc()", "IServiceCollection.AddMvc()",
"IApplicationBuilder.UseServices(...)", "IApplicationBuilder.ConfigureServices(...)",
"IApplicationBuilder.UseMvc(...)")); "IApplicationBuilder.UseMvc(...)"));
} }
} }

View File

@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Mvc
= new ResourceManager("Microsoft.AspNet.Mvc.Resources", typeof(Resources).GetTypeInfo().Assembly); = new ResourceManager("Microsoft.AspNet.Mvc.Resources", typeof(Resources).GetTypeInfo().Assembly);
/// <summary> /// <summary>
/// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc()/UseServices() in the Application Startup. /// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc() in the Application Startup.
/// </summary> /// </summary>
internal static string UnableToFindServices internal static string UnableToFindServices
{ {
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc
} }
/// <summary> /// <summary>
/// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc()/UseServices() in the Application Startup. /// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc() in the Application Startup.
/// </summary> /// </summary>
internal static string FormatUnableToFindServices() internal static string FormatUnableToFindServices()
{ {

View File

@ -2,15 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Versioning; using System.Runtime.Versioning;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Mvc.Razor;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.Framework.Caching.Memory; using Microsoft.Framework.Caching.Memory;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Runtime; using Microsoft.Framework.Runtime;
@ -56,9 +49,6 @@ namespace Microsoft.AspNet.Mvc
// Create something similar to a HttpContext.RequestServices provider. Necessary because this class is // Create something similar to a HttpContext.RequestServices provider. Necessary because this class is
// instantiated in a lower-level "HttpContext.ApplicationServices" context. One important added service // instantiated in a lower-level "HttpContext.ApplicationServices" context. One important added service
// is an IOptions<RazorViewEngineOptions> but use AddMvc() for simplicity and flexibility. // is an IOptions<RazorViewEngineOptions> but use AddMvc() for simplicity and flexibility.
var serviceCollection = HostingServices.Create(_appServices);
serviceCollection.AddMvc();
// We also need an IApplicationEnvironment with a base path that matches the containing web site, to // We also need an IApplicationEnvironment with a base path that matches the containing web site, to
// find the razor files. We don't have a guarantee that the base path of the current application is // find the razor files. We don't have a guarantee that the base path of the current application is
// this site. For example similar functional test changes to the IApplicationEnvironment happen later, // this site. For example similar functional test changes to the IApplicationEnvironment happen later,
@ -68,10 +58,13 @@ namespace Microsoft.AspNet.Mvc
var precompilationApplicationEnvironment = new PrecompilationApplicationEnvironment( var precompilationApplicationEnvironment = new PrecompilationApplicationEnvironment(
applicationEnvironment, applicationEnvironment,
context.ProjectContext.ProjectDirectory); context.ProjectContext.ProjectDirectory);
serviceCollection.AddInstance<IApplicationEnvironment>(precompilationApplicationEnvironment);
var serviceProvider = serviceCollection.BuildServiceProvider(); var replacedServices = new ServiceCollection();
var viewCompiler = new RazorPreCompiler(serviceProvider, context, _memoryCache, compilationSettings) replacedServices.AddMvc();
replacedServices.AddInstance<IApplicationEnvironment>(precompilationApplicationEnvironment);
var wrappedServices = new WrappingServiceProvider(_appServices, replacedServices);
var viewCompiler = new RazorPreCompiler(wrappedServices, context, _memoryCache, compilationSettings)
{ {
GenerateSymbols = GenerateSymbols GenerateSymbols = GenerateSymbols
}; };
@ -84,6 +77,25 @@ namespace Microsoft.AspNet.Mvc
{ {
} }
// REVIEW: Welcome back to life delegating SP!!!
private class WrappingServiceProvider : IServiceProvider
{
private readonly IServiceProvider _fallback;
private readonly IServiceProvider _override;
// Need full wrap for generics like IOptions
public WrappingServiceProvider(IServiceProvider fallback, IServiceCollection replacedServices)
{
_fallback = fallback;
_override = replacedServices.BuildServiceProvider();
}
public object GetService(Type serviceType)
{
return _override.GetService(serviceType) ?? _fallback.GetService(serviceType);
}
}
private class PrecompilationApplicationEnvironment : IApplicationEnvironment private class PrecompilationApplicationEnvironment : IApplicationEnvironment
{ {
private readonly IApplicationEnvironment _originalApplicationEnvironment; private readonly IApplicationEnvironment _originalApplicationEnvironment;

View File

@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc
services.Setup(o => o.GetService(typeof(IEnumerable<MvcMarkerService>))) services.Setup(o => o.GetService(typeof(IEnumerable<MvcMarkerService>)))
.Returns(new List<MvcMarkerService>()); .Returns(new List<MvcMarkerService>());
var expectedMessage = "Unable to find the required services. Please add all the required " + var expectedMessage = "Unable to find the required services. Please add all the required " +
"services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.UseServices(...)' " + "services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.ConfigureServices(...)' " +
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code."; "or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
// Act & Assert // Act & Assert

View File

@ -10,6 +10,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ActionResultsWebSite; using ActionResultsWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -18,12 +19,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ActionResultsWebSite); private const string SiteName = nameof(ActionResultsWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task BadRequestResult_CanBeReturned() public async Task BadRequestResult_CanBeReturned()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{\"SampleInt\":10}"; var input = "{\"SampleInt\":10}";
@ -45,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CreatedResult_SetsRelativePathInLocationHeader() public async Task CreatedResult_SetsRelativePathInLocationHeader()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -65,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CreatedResult_SetsAbsolutePathInLocationHeader() public async Task CreatedResult_SetsAbsolutePathInLocationHeader()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -85,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CreatedResult_SetsQualifiedPathInLocationHeader() public async Task CreatedResult_SetsQualifiedPathInLocationHeader()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -107,7 +109,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CreatedResult_SetsUriInLocationHeader() public async Task CreatedResult_SetsUriInLocationHeader()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -127,7 +129,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CreatedAtActionResult_GeneratesUri_WithActionAndController() public async Task CreatedAtActionResult_GeneratesUri_WithActionAndController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -147,7 +149,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CreatedAtRouteResult_GeneratesUri_WithRouteValues() public async Task CreatedAtRouteResult_GeneratesUri_WithRouteValues()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -167,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CreatedAtRouteResult_GeneratesUri_WithRouteName() public async Task CreatedAtRouteResult_GeneratesUri_WithRouteName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -187,7 +189,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SerializableError_CanSerializeNormalObjects() public async Task SerializableError_CanSerializeNormalObjects()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
@ -210,7 +212,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ContentResult_WritesContent_SetsDefaultContentTypeAndEncoding() public async Task ContentResult_WritesContent_SetsDefaultContentTypeAndEncoding()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, HttpMethod.Post,
@ -230,7 +232,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ContentResult_WritesContent_SetsContentTypeWithDefaultEncoding() public async Task ContentResult_WritesContent_SetsContentTypeWithDefaultEncoding()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, HttpMethod.Post,
@ -250,7 +252,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ContentResult_WritesContent_SetsContentTypeAndEncoding() public async Task ContentResult_WritesContent_SetsContentTypeAndEncoding()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, HttpMethod.Post,
@ -270,7 +272,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ObjectResult_WithStatusCodeAndNoContent_SetsSameStatusCode() public async Task ObjectResult_WithStatusCodeAndNoContent_SetsSameStatusCode()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Get, HttpMethod.Get,
@ -287,7 +289,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task HttpNotFoundObjectResult_NoResponseContent() public async Task HttpNotFoundObjectResult_NoResponseContent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -306,7 +308,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task HttpNotFoundObjectResult_WithResponseContent() public async Task HttpNotFoundObjectResult_WithResponseContent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -325,7 +327,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task HttpNotFoundObjectResult_WithDisposableObject() public async Task HttpNotFoundObjectResult_WithDisposableObject()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var nameValueCollection = new List<KeyValuePair<string, string>> var nameValueCollection = new List<KeyValuePair<string, string>>
{ {

View File

@ -5,6 +5,7 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using ActivatorWebSite; using ActivatorWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -13,12 +14,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ActivatorWebSite); private const string SiteName = nameof(ActivatorWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task ControllerThatCannotBeActivated_ThrowsWhenAttemptedToBeInvoked() public async Task ControllerThatCannotBeActivated_ThrowsWhenAttemptedToBeInvoked()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMessage = "The property 'Service' on controller 'ActivatorWebSite.CannotBeActivatedController' " + var expectedMessage = "The property 'Service' on controller 'ActivatorWebSite.CannotBeActivatedController' " +
@ -36,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PropertiesForPocoControllersAreInitialized() public async Task PropertiesForPocoControllersAreInitialized()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = "4|some-text"; var expected = "4|some-text";
@ -54,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PropertiesForTypesDerivingFromControllerAreInitialized() public async Task PropertiesForTypesDerivingFromControllerAreInitialized()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = "Hello world"; var expected = "Hello world";
@ -69,7 +71,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewActivator_ActivatesDefaultInjectedProperties() public async Task ViewActivator_ActivatesDefaultInjectedProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = @"<label for=""Hello"">Hello</label> world! /View/ConsumeServicesFromBaseType"; var expected = @"<label for=""Hello"">Hello</label> world! /View/ConsumeServicesFromBaseType";
@ -84,7 +86,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewActivator_ActivatesAndContextualizesInjectedServices() public async Task ViewActivator_ActivatesAndContextualizesInjectedServices()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = "4 test-value"; var expected = "4 test-value";
@ -99,7 +101,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewActivator_ActivatesServicesFromBaseType() public async Task ViewActivator_ActivatesServicesFromBaseType()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = @"/content/scripts/test.js"; var expected = @"/content/scripts/test.js";
@ -114,7 +116,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewComponentActivator_ActivatesProperties() public async Task ViewComponentActivator_ActivatesProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = @"Random Number:4"; var expected = @"Random Number:4";
@ -129,7 +131,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewComponentActivator_ActivatesPropertiesAndContextualizesThem() public async Task ViewComponentActivator_ActivatesPropertiesAndContextualizesThem()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = "test-value"; var expected = "test-value";
@ -144,7 +146,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewComponentActivator_ActivatesPropertiesAndContextualizesThem_WhenMultiplePropertiesArePresent() public async Task ViewComponentActivator_ActivatesPropertiesAndContextualizesThem_WhenMultiplePropertiesArePresent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = "Random Number:4 test-value"; var expected = "Random Number:4 test-value";
@ -159,7 +161,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewComponentThatCannotBeActivated_ThrowsWhenAttemptedToBeInvoked() public async Task ViewComponentThatCannotBeActivated_ThrowsWhenAttemptedToBeInvoked()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMessage = "No service for type 'ActivatorWebSite.CannotBeActivatedComponent+FakeType' " + var expectedMessage = "No service for type 'ActivatorWebSite.CannotBeActivatedComponent+FakeType' " +
"has been registered."; "has been registered.";
@ -176,7 +178,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TagHelperActivation_ActivateHtmlHelper_RendersProperly() public async Task TagHelperActivation_ActivateHtmlHelper_RendersProperly()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = "<body><h2>Activation Test</h2>" + var expected = "<body><h2>Activation Test</h2>" +
Environment.NewLine + Environment.NewLine +

View File

@ -8,6 +8,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -16,12 +17,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(AntiForgeryWebSite); private const string SiteName = nameof(AntiForgeryWebSite);
private readonly Action<IApplicationBuilder> _app = new AntiForgeryWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new AntiForgeryWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new AntiForgeryWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task MultipleAFTokensWithinTheSamePage_GeneratesASingleCookieToken() public async Task MultipleAFTokensWithinTheSamePage_GeneratesASingleCookieToken()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -44,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MultipleFormPostWithingASingleView_AreAllowed() public async Task MultipleFormPostWithingASingleView_AreAllowed()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// do a get response. // do a get response.
@ -79,7 +81,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task InvalidCookieToken_Throws() public async Task InvalidCookieToken_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var getResponse = await client.GetAsync("http://localhost/Account/Login"); var getResponse = await client.GetAsync("http://localhost/Account/Login");
@ -111,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task InvalidFormToken_Throws() public async Task InvalidFormToken_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var getResponse = await client.GetAsync("http://localhost/Account/Login"); var getResponse = await client.GetAsync("http://localhost/Account/Login");
@ -141,7 +143,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task IncompatibleCookieToken_Throws() public async Task IncompatibleCookieToken_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// do a get response. // do a get response.
@ -179,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MissingCookieToken_Throws() public async Task MissingCookieToken_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// do a get response. // do a get response.
@ -209,7 +211,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MissingAFToken_Throws() public async Task MissingAFToken_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var getResponse = await client.GetAsync("http://localhost/Account/Login"); var getResponse = await client.GetAsync("http://localhost/Account/Login");
var resposneBody = await getResponse.Content.ReadAsStringAsync(); var resposneBody = await getResponse.Content.ReadAsStringAsync();
@ -238,7 +240,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SetCookieAndHeaderBeforeFlushAsync_GeneratesCookieTokenAndHeader() public async Task SetCookieAndHeaderBeforeFlushAsync_GeneratesCookieTokenAndHeader()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -258,7 +260,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SetCookieAndHeaderBeforeFlushAsync_PostToForm() public async Task SetCookieAndHeaderBeforeFlushAsync_PostToForm()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// do a get response. // do a get response.

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -17,12 +18,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ApiExplorerWebSite); private const string SiteName = nameof(ApiExplorerWebSite);
private readonly Action<IApplicationBuilder> _app = new ApiExplorerWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ApiExplorerWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ApiExplorerWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ApiExplorer_IsVisible_EnabledWithConvention() public async Task ApiExplorer_IsVisible_EnabledWithConvention()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -39,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_IsVisible_DisabledWithConvention() public async Task ApiExplorer_IsVisible_DisabledWithConvention()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -56,7 +58,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_IsVisible_DisabledWithAttribute() public async Task ApiExplorer_IsVisible_DisabledWithAttribute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -73,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_IsVisible_EnabledWithAttribute() public async Task ApiExplorer_IsVisible_EnabledWithAttribute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -90,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_GroupName_SetByConvention() public async Task ApiExplorer_GroupName_SetByConvention()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -108,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_GroupName_SetByAttributeOnController() public async Task ApiExplorer_GroupName_SetByAttributeOnController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -126,7 +128,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_GroupName_SetByAttributeOnAction() public async Task ApiExplorer_GroupName_SetByAttributeOnAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -144,7 +146,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplate_DisplaysFixedRoute() public async Task ApiExplorer_RouteTemplate_DisplaysFixedRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -162,7 +164,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplate_DisplaysRouteWithParameters() public async Task ApiExplorer_RouteTemplate_DisplaysRouteWithParameters()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -186,7 +188,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplate_StripsInlineConstraintsFromThePath() public async Task ApiExplorer_RouteTemplate_StripsInlineConstraintsFromThePath()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/Constraint/5"; var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/Constraint/5";
@ -211,7 +213,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplate_StripsCatchAllsFromThePath() public async Task ApiExplorer_RouteTemplate_StripsCatchAllsFromThePath()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/CatchAll/5"; var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/CatchAll/5";
@ -235,7 +237,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplate_StripsCatchAllsWithConstraintsFromThePath() public async Task ApiExplorer_RouteTemplate_StripsCatchAllsWithConstraintsFromThePath()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/CatchAllAndConstraint/5"; var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/CatchAllAndConstraint/5";
@ -262,7 +264,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplateStripsMultipleConstraints_OnTheSamePathSegment() public async Task ApiExplorer_RouteTemplateStripsMultipleConstraints_OnTheSamePathSegment()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/" var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/"
@ -301,7 +303,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplateStripsMultipleConstraints_InMultipleSegments() public async Task ApiExplorer_RouteTemplateStripsMultipleConstraints_InMultipleSegments()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/" var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/"
+ "MultipleParametersInMultipleSegments/12/01/1987"; + "MultipleParametersInMultipleSegments/12/01/1987";
@ -339,7 +341,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_DescribeParameters_FromAllSources() public async Task ApiExplorer_DescribeParameters_FromAllSources()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/MultipleTypesOfParameters/1/2/3"; var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/MultipleTypesOfParameters/1/2/3";
@ -370,7 +372,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_RouteTemplate_MakesParametersOptional() public async Task ApiExplorer_RouteTemplate_MakesParametersOptional()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -392,7 +394,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_HttpMethod_All() public async Task ApiExplorer_HttpMethod_All()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -410,7 +412,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_HttpMethod_Single() public async Task ApiExplorer_HttpMethod_Single()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -432,7 +434,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_HttpMethod_Single(string httpMethod) public async Task ApiExplorer_HttpMethod_Single(string httpMethod)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -458,7 +460,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseType_VoidWithoutAttribute(string action) public async Task ApiExplorer_ResponseType_VoidWithoutAttribute(string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -483,7 +485,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseType_UnknownWithoutAttribute(string action) public async Task ApiExplorer_ResponseType_UnknownWithoutAttribute(string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -506,7 +508,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseType_KnownWithoutAttribute(string action, string type) public async Task ApiExplorer_ResponseType_KnownWithoutAttribute(string action, string type)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -530,7 +532,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseType_KnownWithAttribute(string action, string type) public async Task ApiExplorer_ResponseType_KnownWithAttribute(string action, string type)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -551,7 +553,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseType_OverrideOnAction(string action, string type) public async Task ApiExplorer_ResponseType_OverrideOnAction(string action, string type)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -570,7 +572,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseContentType_Unset() public async Task ApiExplorer_ResponseContentType_Unset()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -600,7 +602,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseContentType_Specific() public async Task ApiExplorer_ResponseContentType_Specific()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -626,7 +628,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ResponseContentType_NoMatch() public async Task ApiExplorer_ResponseContentType_NoMatch()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -651,7 +653,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string formatterType) string formatterType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -673,7 +675,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_Parameters_SimpleTypes_Default() public async Task ApiExplorer_Parameters_SimpleTypes_Default()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -701,7 +703,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_Parameters_SimpleTypes_BinderMetadataOnParameters() public async Task ApiExplorer_Parameters_SimpleTypes_BinderMetadataOnParameters()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -729,7 +731,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_ParametersSimpleModel() public async Task ApiExplorer_ParametersSimpleModel()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -753,7 +755,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_Parameters_SimpleTypes_SimpleModel_FromBody() public async Task ApiExplorer_Parameters_SimpleTypes_SimpleModel_FromBody()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -781,7 +783,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiExplorer_Parameters_SimpleTypes_ComplexModel() public async Task ApiExplorer_Parameters_SimpleTypes_ComplexModel()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -14,12 +15,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ApplicationModelWebSite); private const string SiteName = nameof(ApplicationModelWebSite);
private readonly Action<IApplicationBuilder> _app = new ApplicationModelWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ApplicationModelWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ApplicationModelWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ControllerModel_CustomizedWithAttribute() public async Task ControllerModel_CustomizedWithAttribute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -36,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionModel_CustomizedWithAttribute() public async Task ActionModel_CustomizedWithAttribute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -53,7 +55,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ParameterModel_CustomizedWithAttribute() public async Task ParameterModel_CustomizedWithAttribute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -70,7 +72,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApplicationModel_AddPropertyToActionDescriptor_FromApplicationModel() public async Task ApplicationModel_AddPropertyToActionDescriptor_FromApplicationModel()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -87,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApplicationModel_AddPropertyToActionDescriptor_ControllerModelOverwritesCommonApplicationProperty() public async Task ApplicationModel_AddPropertyToActionDescriptor_ControllerModelOverwritesCommonApplicationProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -104,7 +106,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApplicationModel_ProvidesMetadataToActionDescriptor_ActionModelOverwritesControllerModelProperty() public async Task ApplicationModel_ProvidesMetadataToActionDescriptor_ActionModelOverwritesControllerModelProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -121,7 +123,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApplicationModelExtensions_AddsConventionToAllControllers() public async Task ApplicationModelExtensions_AddsConventionToAllControllers()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -140,7 +142,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApplicationModelExtensions_AddsConventionToAllActions() public async Task ApplicationModelExtensions_AddsConventionToAllActions()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/GetHelloWorld"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/GetHelloWorld");

View File

@ -10,6 +10,7 @@ using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using BasicWebSite; using BasicWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -19,6 +20,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(BasicWebSite); private const string SiteName = nameof(BasicWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
// Some tests require comparing the actual response body against an expected response baseline // Some tests require comparing the actual response body against an expected response baseline
// so they require a reference to the assembly on which the resources are located, in order to // so they require a reference to the assembly on which the resources are located, in order to
@ -33,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanRender_ViewsWithLayout(string url) public async Task CanRender_ViewsWithLayout(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8"); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
@ -57,7 +59,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanRender_SimpleViews() public async Task CanRender_SimpleViews()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync("compiler/resources/BasicWebSite.Home.PlainView.html"); var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync("compiler/resources/BasicWebSite.Home.PlainView.html");
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8"); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
@ -77,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanReturn_ResultsWithoutContent() public async Task CanReturn_ResultsWithoutContent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -95,7 +97,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ReturningTaskFromAction_ProducesNoContentResult() public async Task ReturningTaskFromAction_ProducesNoContentResult()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -110,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionDescriptors_CreatedOncePerRequest() public async Task ActionDescriptors_CreatedOncePerRequest()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContent = "1"; var expectedContent = "1";
@ -130,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionWithRequireHttps_RedirectsToSecureUrl_ForNonHttpsGetRequests() public async Task ActionWithRequireHttps_RedirectsToSecureUrl_ForNonHttpsGetRequests()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -150,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionWithRequireHttps_ReturnsBadRequestResponse_ForNonHttpsNonGetRequests() public async Task ActionWithRequireHttps_ReturnsBadRequestResponse_ForNonHttpsNonGetRequests()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -172,7 +174,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionWithRequireHttps_AllowsHttpsRequests(string method) public async Task ActionWithRequireHttps_AllowsHttpsRequests(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = new HttpClient(server.CreateHandler(), false); var client = new HttpClient(server.CreateHandler(), false);
// Act // Act
@ -188,7 +190,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonViewComponent_RendersJson() public async Task JsonViewComponent_RendersJson()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = new HttpClient(server.CreateHandler(), false); var client = new HttpClient(server.CreateHandler(), false);
var expectedBody = JsonConvert.SerializeObject(new BasicWebSite.Models.Person() var expectedBody = JsonConvert.SerializeObject(new BasicWebSite.Models.Person()
{ {
@ -247,7 +249,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task HtmlHelperLinkGeneration(string viewName, string expectedLink) public async Task HtmlHelperLinkGeneration(string viewName, string expectedLink)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = new HttpClient(server.CreateHandler(), false); var client = new HttpClient(server.CreateHandler(), false);
// Act // Act
@ -263,7 +265,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConfigureMvc_AddsOptionsProperly() public async Task ConfigureMvc_AddsOptionsProperly()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = new HttpClient(server.CreateHandler(), false); var client = new HttpClient(server.CreateHandler(), false);
// Act // Act
@ -279,7 +281,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TypesWithoutControllerSuffix_DerivingFromTypesWithControllerSuffix_CanBeAccessed() public async Task TypesWithoutControllerSuffix_DerivingFromTypesWithControllerSuffix_CanBeAccessed()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = new HttpClient(server.CreateHandler(), false); var client = new HttpClient(server.CreateHandler(), false);
// Act // Act
@ -293,7 +295,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TypesMarkedAsNonAction_AreInaccessible() public async Task TypesMarkedAsNonAction_AreInaccessible()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = new HttpClient(server.CreateHandler(), false); var client = new HttpClient(server.CreateHandler(), false);
// Act // Act

View File

@ -6,6 +6,7 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(BestEffortLinkGenerationWebSite); private const string SiteName = nameof(BestEffortLinkGenerationWebSite);
private readonly Action<IApplicationBuilder> _app = new BestEffortLinkGenerationWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new BestEffortLinkGenerationWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new BestEffortLinkGenerationWebSite.Startup().ConfigureServices;
private const string ExpectedOutput = @"<html> private const string ExpectedOutput = @"<html>
<body> <body>
@ -26,7 +28,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GenerateLink_NonExistentAction() public async Task GenerateLink_NonExistentAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/Home/Index"; var url = "http://localhost/Home/Index";

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using RazorWebSite; using RazorWebSite;
using Xunit; using Xunit;
@ -15,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RazorWebSite); private const string SiteName = nameof(RazorWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task CompilationOptions_AreUsedByViewsAndPartials() public async Task CompilationOptions_AreUsedByViewsAndPartials()
@ -31,7 +33,7 @@ This method is only defined in DNX451";
This method is only defined in DNXCORE50"; This method is only defined in DNXCORE50";
#endif #endif
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -12,12 +13,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(CompositeViewEngineWebSite); private const string SiteName = nameof(CompositeViewEngineWebSite);
private readonly Action<IApplicationBuilder> _app = new CompositeViewEngineWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new CompositeViewEngineWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new CompositeViewEngineWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task CompositeViewEngine_FindsPartialViewsAcrossAllEngines() public async Task CompositeViewEngine_FindsPartialViewsAcrossAllEngines()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -31,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CompositeViewEngine_FindsViewsAcrossAllEngines() public async Task CompositeViewEngine_FindsViewsAcrossAllEngines()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ActionConstraintsWebSite; using ActionConstraintsWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -17,12 +18,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ActionConstraintsWebSite); private const string SiteName = nameof(ActionConstraintsWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task NoRequestContentType_SelectsActionWithoutConstraint() public async Task NoRequestContentType_SelectsActionWithoutConstraint()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, HttpMethod.Post,
@ -41,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoRequestContentType_Throws_IfMultipleActionsWithConstraints() public async Task NoRequestContentType_Throws_IfMultipleActionsWithConstraints()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, HttpMethod.Post,
@ -65,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoRequestContentType_Selects_IfASingleActionWithConstraintIsPresent() public async Task NoRequestContentType_Selects_IfASingleActionWithConstraintIsPresent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -87,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task Selects_Action_BasedOnRequestContentType(string requestContentType) public async Task Selects_Action_BasedOnRequestContentType(string requestContentType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{SampleString:\""+requestContentType+"\"}"; var input = "{SampleString:\""+requestContentType+"\"}";
@ -110,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionLevelAttribute_OveridesClassLevel(string requestContentType) public async Task ActionLevelAttribute_OveridesClassLevel(string requestContentType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{SampleString:\"" + requestContentType + "\"}"; var input = "{SampleString:\"" + requestContentType + "\"}";
@ -133,7 +135,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task DerivedClassLevelAttribute_OveridesBaseClassLevel() public async Task DerivedClassLevelAttribute_OveridesBaseClassLevel()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "<Product xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" " + var input = "<Product xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" " +

View File

@ -10,6 +10,7 @@ using System.Threading.Tasks;
using ContentNegotiationWebSite; using ContentNegotiationWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -18,12 +19,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ContentNegotiationWebSite); private const string SiteName = nameof(ContentNegotiationWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task ProducesAttribute_SingleContentType_PicksTheFirstSupportedFormatter() public async Task ProducesAttribute_SingleContentType_PicksTheFirstSupportedFormatter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Selects custom even though it is last in the list. // Selects custom even though it is last in the list.
@ -43,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ProducesAttribute_MultipleContentTypes_RunsConnegToSelectFormatter() public async Task ProducesAttribute_MultipleContentTypes_RunsConnegToSelectFormatter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
var expectedBody = "{\r\n \"Name\": \"My name\",\r\n \"Address\": \"My address\"\r\n}"; var expectedBody = "{\r\n \"Name\": \"My name\",\r\n \"Address\": \"My address\"\r\n}";
@ -61,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoProducesAttribute_ActionReturningString_RunsUsingTextFormatter() public async Task NoProducesAttribute_ActionReturningString_RunsUsingTextFormatter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("text/plain;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("text/plain;charset=utf-8");
var expectedBody = "NormalController"; var expectedBody = "NormalController";
@ -79,7 +81,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoProducesAttribute_ActionReturningAnyObject_RunsUsingDefaultFormatters() public async Task NoProducesAttribute_ActionReturningAnyObject_RunsUsingDefaultFormatters()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
@ -94,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ProducesAttributeWithTypeOnly_RunsRegularContentNegotiation() public async Task ProducesAttributeWithTypeOnly_RunsRegularContentNegotiation()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
@ -114,7 +116,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ProducesAttribute_WithTypeAndContentType_UsesContentType() public async Task ProducesAttribute_WithTypeAndContentType_UsesContentType()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml")); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
var expectedContentType = MediaTypeHeaderValue.Parse("application/xml;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/xml;charset=utf-8");
@ -138,7 +140,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoAcceptAndRequestContentTypeHeaders_UsesFirstFormatterWhichCanWriteType(string url) public async Task NoAcceptAndRequestContentTypeHeaders_UsesFirstFormatterWhichCanWriteType(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
@ -156,7 +158,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoMatchingFormatter_ForTheGivenContentType_Returns406() public async Task NoMatchingFormatter_ForTheGivenContentType_Returns406()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -175,7 +177,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string expectedResponseBody) string expectedResponseBody)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
expectedResponseBody = expectedResponseBody.Replace("#", Environment.NewLine); expectedResponseBody = expectedResponseBody.Replace("#", Environment.NewLine);
@ -196,7 +198,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task ProducesAttribute_OnAction_OverridesTheValueOnClass() public async Task ProducesAttribute_OnAction_OverridesTheValueOnClass()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Value on the class is application/json. // Value on the class is application/json.
@ -216,7 +218,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task ProducesAttribute_OnDerivedClass_OverridesTheValueOnBaseClass() public async Task ProducesAttribute_OnDerivedClass_OverridesTheValueOnBaseClass()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse( var expectedContentType = MediaTypeHeaderValue.Parse(
"application/custom_ProducesContentOnClassController;charset=utf-8"); "application/custom_ProducesContentOnClassController;charset=utf-8");
@ -235,7 +237,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseClass() public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseClass()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse( var expectedContentType = MediaTypeHeaderValue.Parse(
"application/custom_NoProducesContentOnClassController_Action;charset=utf-8"); "application/custom_NoProducesContentOnClassController_Action;charset=utf-8");
@ -253,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseAction() public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseAction()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse( var expectedContentType = MediaTypeHeaderValue.Parse(
"application/custom_NoProducesContentOnClassController_Action;charset=utf-8"); "application/custom_NoProducesContentOnClassController_Action;charset=utf-8");
@ -272,7 +274,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ProducesAttribute_OnDerivedClassAndAction_OverridesTheValueOnBaseClass() public async Task ProducesAttribute_OnDerivedClassAndAction_OverridesTheValueOnBaseClass()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse( var expectedContentType = MediaTypeHeaderValue.Parse(
"application/custom_ProducesContentOnClassController_Action;charset=utf-8"); "application/custom_ProducesContentOnClassController_Action;charset=utf-8");
@ -291,7 +293,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ProducesAttribute_IsNotHonored_ForJsonResult() public async Task ProducesAttribute_IsNotHonored_ForJsonResult()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
var expectedBody = "{\"MethodName\":\"Produces_WithNonObjectResult\"}"; var expectedBody = "{\"MethodName\":\"Produces_WithNonObjectResult\"}";
@ -309,7 +311,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_UsesDefaultContentTypes_IfNoneAreAddedExplicitly() public async Task JsonResult_UsesDefaultContentTypes_IfNoneAreAddedExplicitly()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
var expectedBody = "{\"MethodName\":\"ReturnJsonResult\"}"; var expectedBody = "{\"MethodName\":\"ReturnJsonResult\"}";
@ -327,7 +329,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_UsesExplicitContentTypeAndFormatter_IfAdded() public async Task JsonResult_UsesExplicitContentTypeAndFormatter_IfAdded()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/custom-json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/custom-json;charset=utf-8");
var expectedBody = "{ MethodName = ReturnJsonResult_WithCustomMediaType }"; var expectedBody = "{ MethodName = ReturnJsonResult_WithCustomMediaType }";
@ -345,7 +347,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_UsesDefaultJsonFormatter_IfNoMatchingFormatterIsFound() public async Task JsonResult_UsesDefaultJsonFormatter_IfNoMatchingFormatterIsFound()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
var expectedBody = "{\"MethodName\":\"ReturnJsonResult_WithCustomMediaType_NoFormatter\"}"; var expectedBody = "{\"MethodName\":\"ReturnJsonResult_WithCustomMediaType_NoFormatter\"}";
@ -363,7 +365,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonFormatter_SupportedMediaType_DoesNotChangeAcrossRequests() public async Task JsonFormatter_SupportedMediaType_DoesNotChangeAcrossRequests()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
var expectedBody = "{\"MethodName\":\"ReturnJsonResult\"}"; var expectedBody = "{\"MethodName\":\"ReturnJsonResult\"}";
@ -383,7 +385,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task XmlFormatter_SupportedMediaType_DoesNotChangeAcrossRequests() public async Task XmlFormatter_SupportedMediaType_DoesNotChangeAcrossRequests()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml")); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
client.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8")); client.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));
@ -409,7 +411,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoMatchOn_RequestContentType_FallsBackOnTypeBasedMatch_MatchFound(string actionName) public async Task NoMatchOn_RequestContentType_FallsBackOnTypeBasedMatch_MatchFound(string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
var expectedBody = "1234"; var expectedBody = "1234";
@ -434,7 +436,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ObjectResult_WithStringReturnType_WritesTextPlainFormat(bool matchFormatterOnObjectType) public async Task ObjectResult_WithStringReturnType_WritesTextPlainFormat(bool matchFormatterOnObjectType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var targetUri = "http://localhost/FallbackOnTypeBasedMatch/ReturnString?matchFormatterOnObjectType=" + var targetUri = "http://localhost/FallbackOnTypeBasedMatch/ReturnString?matchFormatterOnObjectType=" +
matchFormatterOnObjectType; matchFormatterOnObjectType;
@ -457,7 +459,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoMatchOn_RequestContentType_SkipTypeMatchByAddingACustomFormatter(string actionName) public async Task NoMatchOn_RequestContentType_SkipTypeMatchByAddingACustomFormatter(string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var targetUri = "http://localhost/FallbackOnTypeBasedMatch/" + actionName + "/?input=1234"; var targetUri = "http://localhost/FallbackOnTypeBasedMatch/" + actionName + "/?input=1234";
var content = new StringContent("1234", Encoding.UTF8, "application/custom"); var content = new StringContent("1234", Encoding.UTF8, "application/custom");
@ -476,7 +478,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoMatchOn_RequestContentType_FallsBackOnTypeBasedMatch_NoMatchFound_Returns406() public async Task NoMatchOn_RequestContentType_FallsBackOnTypeBasedMatch_NoMatchFound_Returns406()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var targetUri = "http://localhost/FallbackOnTypeBasedMatch/FallbackGivesNoMatch/?input=1234"; var targetUri = "http://localhost/FallbackOnTypeBasedMatch/FallbackGivesNoMatch/?input=1234";
var content = new StringContent("1234", Encoding.UTF8, "application/custom"); var content = new StringContent("1234", Encoding.UTF8, "application/custom");
@ -495,7 +497,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ProducesAttribute_And_FormatFilterAttribute_Conflicting() public async Task ProducesAttribute_And_FormatFilterAttribute_Conflicting()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json");
@ -510,7 +512,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ProducesAttribute_And_FormatFilterAttribute_Collaborating() public async Task ProducesAttribute_And_FormatFilterAttribute_Collaborating()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -18,12 +18,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ControllerDiscoveryConventionsWebSite); private const string SiteName = nameof(ControllerDiscoveryConventionsWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task AbstractControllers_AreSkipped() public async Task AbstractControllers_AreSkipped()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost/"); client.BaseAddress = new Uri("http://localhost/");
@ -38,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TypesDerivingFromControllerBaseTypesThatDoNotReferenceMvc_AreSkipped() public async Task TypesDerivingFromControllerBaseTypesThatDoNotReferenceMvc_AreSkipped()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost/"); client.BaseAddress = new Uri("http://localhost/");
@ -53,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TypesMarkedWithNonController_AreSkipped() public async Task TypesMarkedWithNonController_AreSkipped()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost/"); client.BaseAddress = new Uri("http://localhost/");
@ -68,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PocoTypesWithControllerSuffix_AreDiscovered() public async Task PocoTypesWithControllerSuffix_AreDiscovered()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost/"); client.BaseAddress = new Uri("http://localhost/");
@ -84,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TypesDerivingFromTypesWithControllerSuffix_AreDiscovered() public async Task TypesDerivingFromTypesWithControllerSuffix_AreDiscovered()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost/"); client.BaseAddress = new Uri("http://localhost/");
@ -106,7 +107,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var server = TestHelper.CreateServer( var server = TestHelper.CreateServer(
_app, _app,
SiteName, SiteName,
services => services.AddTransient<IAssemblyProvider, FilteredDefaultAssemblyProvider>()); services =>
{
_configureServices(services);
services.AddTransient<IAssemblyProvider, FilteredDefaultAssemblyProvider>();
});
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost/"); client.BaseAddress = new Uri("http://localhost/");

View File

@ -7,6 +7,7 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using ControllersFromServicesWebSite; using ControllersFromServicesWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,13 +16,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ControllersFromServicesWebSite); private const string SiteName = nameof(ControllersFromServicesWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Func<IServiceCollection, IServiceProvider> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task ControllersWithConstructorInjectionAreCreatedAndActivated() public async Task ControllersWithConstructorInjectionAreCreatedAndActivated()
{ {
// Arrange // Arrange
var expected = "/constructorinjection 14 test-header-value"; var expected = "/constructorinjection 14 test-header-value";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.TryAddWithoutValidation("Test-Header", "test-header-value"); client.DefaultRequestHeaders.TryAddWithoutValidation("Test-Header", "test-header-value");
@ -37,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = "No schedules available for 23"; var expected = "No schedules available for 23";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -52,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = "4"; var expected = "4";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -67,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = "Updated record employee303"; var expected = "Updated record employee303";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -84,7 +86,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = "Saved record employee #211"; var expected = "Saved record employee #211";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -104,7 +106,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AddControllersFromServices_UsesControllerDiscoveryContentions(string action) public async Task AddControllersFromServices_UsesControllerDiscoveryContentions(string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -7,7 +7,7 @@ using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Cors.Core;
using Microsoft.AspNet.Http; using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(CorsMiddlewareWebSite); private const string SiteName = nameof(CorsMiddlewareWebSite);
private readonly Action<IApplicationBuilder> _app = new CorsMiddlewareWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new CorsMiddlewareWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new CorsMiddlewareWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("GET")] [InlineData("GET")]
@ -24,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResourceWithSimpleRequestPolicy_Allows_SimpleRequests(string method) public async Task ResourceWithSimpleRequestPolicy_Allows_SimpleRequests(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var origin = "http://example.com"; var origin = "http://example.com";
@ -53,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PolicyFailed_Disallows_PreFlightRequest(string method) public async Task PolicyFailed_Disallows_PreFlightRequest(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Adding a custom header makes it a non simple request. // Adding a custom header makes it a non simple request.
@ -80,7 +81,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PolicyFailed_Allows_ActualRequest_WithMissingResponseHeaders() public async Task PolicyFailed_Allows_ActualRequest_WithMissingResponseHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Adding a custom header makes it a non simple request. // Adding a custom header makes it a non simple request.

View File

@ -7,7 +7,7 @@ using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Cors.Core;
using Microsoft.AspNet.Http; using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(CorsWebSite); private const string SiteName = nameof(CorsWebSite);
private readonly Action<IApplicationBuilder> _app = new CorsWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new CorsWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new CorsWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("GET")] [InlineData("GET")]
@ -24,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResourceWithSimpleRequestPolicy_Allows_SimpleRequests(string method) public async Task ResourceWithSimpleRequestPolicy_Allows_SimpleRequests(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var origin = "http://example.com"; var origin = "http://example.com";
@ -53,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PolicyFailed_Disallows_PreFlightRequest(string method) public async Task PolicyFailed_Disallows_PreFlightRequest(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Adding a custom header makes it a non simple request. // Adding a custom header makes it a non simple request.
@ -80,7 +81,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SuccessfulCorsRequest_AllowsCredentials_IfThePolicyAllowsCredentials() public async Task SuccessfulCorsRequest_AllowsCredentials_IfThePolicyAllowsCredentials()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Adding a custom header makes it a non simple request. // Adding a custom header makes it a non simple request.
@ -113,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SuccessfulPreflightRequest_AllowsCredentials_IfThePolicyAllowsCredentials() public async Task SuccessfulPreflightRequest_AllowsCredentials_IfThePolicyAllowsCredentials()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Adding a custom header makes it a non simple request. // Adding a custom header makes it a non simple request.
@ -150,7 +151,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PolicyFailed_Allows_ActualRequest_WithMissingResponseHeaders() public async Task PolicyFailed_Allows_ActualRequest_WithMissingResponseHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Adding a custom header makes it a non simple request. // Adding a custom header makes it a non simple request.
@ -178,7 +179,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task DisableCors_ActionsCanOverride_ControllerLevel(string method) public async Task DisableCors_ActionsCanOverride_ControllerLevel(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Exclusive content is not available on other sites. // Exclusive content is not available on other sites.
@ -205,7 +206,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task DisableCors_PreFlight_ActionsCanOverride_ControllerLevel(string method) public async Task DisableCors_PreFlight_ActionsCanOverride_ControllerLevel(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Exclusive content is not available on other sites. // Exclusive content is not available on other sites.

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -14,6 +15,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(CustomRouteWebSite); private const string SiteName = nameof(CustomRouteWebSite);
private readonly Action<IApplicationBuilder> _app = new CustomRouteWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new CustomRouteWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new CustomRouteWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("Javier", "Hola from Spain.")] [InlineData("Javier", "Hola from Spain.")]
@ -22,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RouteToLocale_ConventionalRoute_BasedOnUser(string user, string expected) public async Task RouteToLocale_ConventionalRoute_BasedOnUser(string user, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/CustomRoute_Products/Index"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/CustomRoute_Products/Index");
@ -44,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RouteWithAttributeRoute_IncludesLocale_BasedOnUser(string user, string expected) public async Task RouteWithAttributeRoute_IncludesLocale_BasedOnUser(string user, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/CustomRoute_Orders/5"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/CustomRoute_Orders/5");

View File

@ -5,6 +5,7 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -20,13 +21,15 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(UrlHelperWebSite); private const string SiteName = nameof(UrlHelperWebSite);
private readonly Action<IApplicationBuilder> _app = new UrlHelperWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new UrlHelperWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new UrlHelperWebSite.Startup().ConfigureServices;
private const string _cdnServerBaseUrl = "http://cdn.contoso.com"; private const string _cdnServerBaseUrl = "http://cdn.contoso.com";
[Fact] [Fact]
public async Task CustomUrlHelper_GeneratesUrlFromController() public async Task CustomUrlHelper_GeneratesUrlFromController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -42,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CustomUrlHelper_GeneratesUrlFromView() public async Task CustomUrlHelper_GeneratesUrlFromView()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -60,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LowercaseUrls_LinkGeneration(string url, string expectedLink) public async Task LowercaseUrls_LinkGeneration(string url, string expectedLink)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -10,6 +10,7 @@ using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Mvc.ViewComponents; using Microsoft.AspNet.Mvc.ViewComponents;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
using Xunit; using Xunit;
@ -20,6 +21,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(BasicWebSite); private const string SiteName = nameof(BasicWebSite);
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new BasicWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData(typeof(IActionDescriptorProvider), typeof(ControllerActionDescriptorProvider), -1000)] [InlineData(typeof(IActionDescriptorProvider), typeof(ControllerActionDescriptorProvider), -1000)]
@ -33,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ServiceOrder_GetOrder(Type serviceType, Type actualType, int order) public async Task ServiceOrder_GetOrder(Type serviceType, Type actualType, int order)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/Order/GetServiceOrder?serviceType=" + serviceType.AssemblyQualifiedName; var url = "http://localhost/Order/GetServiceOrder?serviceType=" + serviceType.AssemblyQualifiedName;

View File

@ -6,6 +6,7 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutofacWebSite; using AutofacWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -14,6 +15,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(AutofacWebSite); private const string SiteName = nameof(AutofacWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Func<IServiceCollection, IServiceProvider> _configureServices = new Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("http://localhost/di", "<p>Builder Output: Hello from builder.</p>")] [InlineData("http://localhost/di", "<p>Builder Output: Hello from builder.</p>")]
@ -22,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange & Act & Assert (does not throw) // Arrange & Act & Assert (does not throw)
// This essentially calls into the Startup.Configuration method // This essentially calls into the Startup.Configuration method
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
// Make a request to start resolving DI pieces // Make a request to start resolving DI pieces
var response = await server.CreateClient().GetAsync(url); var response = await server.CreateClient().GetAsync(url);

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using RazorWebSite; using RazorWebSite;
using Xunit; using Xunit;
@ -13,12 +14,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RazorWebSite); private const string SiteName = nameof(RazorWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task ViewsInheritsUsingsAndInjectDirectivesFromViewStarts() public async Task ViewsInheritsUsingsAndInjectDirectivesFromViewStarts()
{ {
var expected = @"Hello Person1"; var expected = @"Hello Person1";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -32,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewInheritsBasePageFromViewStarts() public async Task ViewInheritsBasePageFromViewStarts()
{ {
var expected = @"WriteLiteral says:layout:Write says:Write says:Hello Person2"; var expected = @"WriteLiteral says:layout:Write says:Write says:Hello Person2";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -8,6 +8,7 @@ using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using ErrorPageMiddlewareWebSite; using ErrorPageMiddlewareWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -19,6 +20,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ErrorPageMiddlewareWebSite); private const string SiteName = nameof(ErrorPageMiddlewareWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
private readonly Assembly _resourcesAssembly = typeof(ErrorPageTests).GetTypeInfo().Assembly; private readonly Assembly _resourcesAssembly = typeof(ErrorPageTests).GetTypeInfo().Assembly;
[Theory] [Theory]
@ -31,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CompilationFailuresAreListedByErrorPageMiddleware(string action, string expected) public async Task CompilationFailuresAreListedByErrorPageMiddleware(string action, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html"); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html");

View File

@ -5,6 +5,7 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -13,12 +14,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FilesWebSite); private const string SiteName = nameof(FilesWebSite);
private readonly Action<IApplicationBuilder> _app = new FilesWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FilesWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FilesWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task FileFromDisk_CanBeEnabled_WithMiddleware() public async Task FileFromDisk_CanBeEnabled_WithMiddleware()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -39,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FileFromDisk_ReturnsFileWithFileName() public async Task FileFromDisk_ReturnsFileWithFileName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -64,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FileFromStream_ReturnsFile() public async Task FileFromStream_ReturnsFile()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -85,7 +88,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FileFromStream_ReturnsFileWithFileName() public async Task FileFromStream_ReturnsFileWithFileName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -110,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FileFromBinaryData_ReturnsFile() public async Task FileFromBinaryData_ReturnsFile()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -131,7 +134,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FileFromBinaryData_ReturnsFileWithFileName() public async Task FileFromBinaryData_ReturnsFileWithFileName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -156,7 +159,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FileFromEmbeddedResources_ReturnsFileWithFileName() public async Task FileFromEmbeddedResources_ReturnsFileWithFileName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedBody = "Sample text file as embedded resource."; var expectedBody = "Sample text file as embedded resource.";

View File

@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -17,6 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FiltersWebSite); private const string SiteName = nameof(FiltersWebSite);
private readonly Action<IApplicationBuilder> _app = new FiltersWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FiltersWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FiltersWebSite.Startup().ConfigureServices;
// A controller can only be an action filter and result filter, so we don't have entries // A controller can only be an action filter and result filter, so we don't have entries
// for the other filter types implemented by the controller. // for the other filter types implemented by the controller.
@ -24,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ListAllFilters() public async Task ListAllFilters()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = new string[] var expected = new string[]
@ -80,7 +82,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AnonymousUsersAreBlocked() public async Task AnonymousUsersAreBlocked()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -94,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AllowsAnonymousUsersToAccessController() public async Task AllowsAnonymousUsersToAccessController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -113,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanAuthorize(string testAction) public async Task CanAuthorize(string testAction)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -129,7 +131,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AllowAnonymousOverridesAuthorize() public async Task AllowAnonymousOverridesAuthorize()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -145,7 +147,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ImpossiblePolicyFailsAuthorize() public async Task ImpossiblePolicyFailsAuthorize()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -160,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ServiceFilterUsesRegisteredServicesAsFilter() public async Task ServiceFilterUsesRegisteredServicesAsFilter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -175,7 +177,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ServiceFilterThrowsIfServiceIsNotRegistered() public async Task ServiceFilterThrowsIfServiceIsNotRegistered()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/RandomNumber/GetAuthorizedRandomNumber"; var url = "http://localhost/RandomNumber/GetAuthorizedRandomNumber";
@ -191,7 +193,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TypeFilterInitializesArguments() public async Task TypeFilterInitializesArguments()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/RandomNumber/GetModifiedRandomNumber?randomNumber=10"; var url = "http://localhost/RandomNumber/GetModifiedRandomNumber?randomNumber=10";
@ -207,7 +209,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TypeFilterThrowsIfServicesAreNotRegistered() public async Task TypeFilterThrowsIfServicesAreNotRegistered()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/RandomNumber/GetHalfOfModifiedRandomNumber?randomNumber=3"; var url = "http://localhost/RandomNumber/GetHalfOfModifiedRandomNumber?randomNumber=3";
@ -223,7 +225,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionFilterOverridesActionExecuted() public async Task ActionFilterOverridesActionExecuted()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -240,7 +242,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResultFilterOverridesOnResultExecuting() public async Task ResultFilterOverridesOnResultExecuting()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -257,7 +259,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResultFilterOverridesOnResultExecuted() public async Task ResultFilterOverridesOnResultExecuted()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -274,7 +276,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task OrderOfExecutionOfFilters_WhenOrderAttribute_IsNotMentioned() public async Task OrderOfExecutionOfFilters_WhenOrderAttribute_IsNotMentioned()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -292,7 +294,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ExceptionsHandledInActionFilters_WillNotShortCircuitResultFilters() public async Task ExceptionsHandledInActionFilters_WillNotShortCircuitResultFilters()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -309,7 +311,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ExceptionFilter_OnAction_ShortCircuitsResultFilters() public async Task ExceptionFilter_OnAction_ShortCircuitsResultFilters()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -328,7 +330,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GlobalExceptionFilter_HandlesAnException() public async Task GlobalExceptionFilter_HandlesAnException()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -345,7 +347,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ExceptionFilter_Scope() public async Task ExceptionFilter_Scope()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -366,7 +368,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionFilter_Scope() public async Task ActionFilter_Scope()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -393,7 +395,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResultFilter_Scope() public async Task ResultFilter_Scope()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -416,7 +418,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FiltersWithOrder() public async Task FiltersWithOrder()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -433,7 +435,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionFiltersWithOrder() public async Task ActionFiltersWithOrder()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -454,7 +456,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResultFiltersWithOrder() public async Task ResultFiltersWithOrder()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -473,7 +475,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionFilterShortCircuitsAction() public async Task ActionFilterShortCircuitsAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -490,7 +492,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResultFilterShortCircuitsResult() public async Task ResultFilterShortCircuitsResult()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -507,7 +509,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ExceptionFilterShortCircuitsAnotherExceptionFilter() public async Task ExceptionFilterShortCircuitsAnotherExceptionFilter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -524,7 +526,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ThrowingFilters_ResultFilter_NotHandledByGlobalExceptionFilter() public async Task ThrowingFilters_ResultFilter_NotHandledByGlobalExceptionFilter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -541,7 +543,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ThrowingFilters_ActionFilter_HandledByGlobalExceptionFilter() public async Task ThrowingFilters_ActionFilter_HandledByGlobalExceptionFilter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -558,7 +560,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ThrowingFilters_AuthFilter_NotHandledByGlobalExceptionFilter() public async Task ThrowingFilters_AuthFilter_NotHandledByGlobalExceptionFilter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -575,7 +577,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ThrowingExceptionFilter_ExceptionFilter_NotHandledByGlobalExceptionFilter() public async Task ThrowingExceptionFilter_ExceptionFilter_NotHandledByGlobalExceptionFilter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -592,7 +594,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var input = "{ sampleInt: 10 }"; var input = "{ sampleInt: 10 }";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Json"); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Json");
@ -617,7 +619,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// There's nothing that can deserialize the body, so the result contains the default // There's nothing that can deserialize the body, so the result contains the default
// value. // value.
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Json"); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Json");

View File

@ -16,12 +16,18 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RazorWebSite); private const string SiteName = nameof(RazorWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task FlushPointsAreExecutedForPagesWithLayouts() public async Task FlushPointsAreExecutedForPagesWithLayouts()
{ {
var waitService = new WaitService(); var waitService = new WaitService();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService)); var server = TestHelper.CreateServer(_app, SiteName,
services =>
{
_configureServices(services);
services.AddInstance(waitService);
});
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -44,7 +50,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FlushPointsAreExecutedForPagesWithoutLayouts() public async Task FlushPointsAreExecutedForPagesWithoutLayouts()
{ {
var waitService = new WaitService(); var waitService = new WaitService();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService)); var server = TestHelper.CreateServer(_app, SiteName,
services =>
{
_configureServices(services);
services.AddInstance(waitService);
});
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -79,7 +90,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FlushPointsAreExecutedForPagesWithComponentsPartialsAndSections(string action, string title) public async Task FlushPointsAreExecutedForPagesWithComponentsPartialsAndSections(string action, string title)
{ {
var waitService = new WaitService(); var waitService = new WaitService();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService)); var server = TestHelper.CreateServer(_app, SiteName,
services =>
{
_configureServices(services);
services.AddInstance(waitService);
});
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -115,7 +131,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var waitService = new WaitService(); var waitService = new WaitService();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService)); var server = TestHelper.CreateServer(_app, SiteName,
services =>
{
_configureServices(services);
services.AddInstance(waitService);
});
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -136,7 +157,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FlushBeforeCallingLayout() public async Task FlushBeforeCallingLayout()
{ {
var waitService = new WaitService(); var waitService = new WaitService();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService)); var server = TestHelper.CreateServer(_app, SiteName,
services =>
{
_configureServices(services);
services.AddInstance(waitService);
});
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMessage = "A layout page cannot be rendered after 'FlushAsync' has been invoked."; var expectedMessage = "A layout page cannot be rendered after 'FlushAsync' has been invoked.";

View File

@ -5,6 +5,7 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -13,12 +14,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FormatFilterWebSite); private const string SiteName = nameof(FormatFilterWebSite);
private readonly Action<IApplicationBuilder> _app = new FormatFilterWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FormatFilterWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FormatFilterWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task FormatFilter_NoExtensionInRequest() public async Task FormatFilter_NoExtensionInRequest()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -33,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_ExtensionInRequest_Default() public async Task FormatFilter_ExtensionInRequest_Default()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -48,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_ExtensionInRequest_Optional() public async Task FormatFilter_ExtensionInRequest_Optional()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -63,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_ExtensionInRequest_Custom() public async Task FormatFilter_ExtensionInRequest_Custom()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -78,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_ExtensionInRequest_CaseInsensitivity() public async Task FormatFilter_ExtensionInRequest_CaseInsensitivity()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -93,7 +95,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_ExtensionInRequest_NonExistant() public async Task FormatFilter_ExtensionInRequest_NonExistant()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -107,7 +109,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_And_ProducesFilter_Match() public async Task FormatFilter_And_ProducesFilter_Match()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -122,7 +124,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_And_ProducesFilter_Conflict() public async Task FormatFilter_And_ProducesFilter_Conflict()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -136,7 +138,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormatFilter_And_OverrideProducesFilter() public async Task FormatFilter_And_OverrideProducesFilter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -8,6 +8,7 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using InlineConstraints; using InlineConstraints;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -17,12 +18,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(InlineConstraintsWebSite); private const string SiteName = nameof(InlineConstraintsWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task RoutingToANonExistantArea_WithExistConstraint_RoutesToCorrectAction() public async Task RoutingToANonExistantArea_WithExistConstraint_RoutesToCorrectAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -38,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RoutingToANonExistantArea_WithoutExistConstraint_RoutesToIncorrectAction() public async Task RoutingToANonExistantArea_WithoutExistConstraint_RoutesToIncorrectAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -56,7 +58,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductById_IntConstraintForOptionalId_IdPresent() public async Task GetProductById_IntConstraintForOptionalId_IdPresent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -75,7 +77,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductById_IntConstraintForOptionalId_NoId() public async Task GetProductById_IntConstraintForOptionalId_NoId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -92,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductById_IntConstraintForOptionalId_NotIntId() public async Task GetProductById_IntConstraintForOptionalId_NotIntId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -106,7 +108,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByName_AlphaContraintForMandatoryName_ValidName() public async Task GetProductByName_AlphaContraintForMandatoryName_ValidName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -124,7 +126,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByName_AlphaContraintForMandatoryName_NonAlphaName() public async Task GetProductByName_AlphaContraintForMandatoryName_NonAlphaName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -138,7 +140,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByName_AlphaContraintForMandatoryName_NoName() public async Task GetProductByName_AlphaContraintForMandatoryName_NoName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -152,7 +154,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByManufacturingDate_DateTimeConstraintForMandatoryDateTime_ValidDateTime() public async Task GetProductByManufacturingDate_DateTimeConstraintForMandatoryDateTime_ValidDateTime()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -172,7 +174,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByCategoryName_StringLengthConstraint_ForOptionalCategoryName_ValidCatName() public async Task GetProductByCategoryName_StringLengthConstraint_ForOptionalCategoryName_ValidCatName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -190,7 +192,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByCategoryName_StringLengthConstraint_ForOptionalCategoryName_InvalidCatName() public async Task GetProductByCategoryName_StringLengthConstraint_ForOptionalCategoryName_InvalidCatName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -205,7 +207,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByCategoryName_StringLength1To20Constraint_ForOptionalCategoryName_NoCatName() public async Task GetProductByCategoryName_StringLength1To20Constraint_ForOptionalCategoryName_NoCatName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -222,7 +224,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_ValidId() public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_ValidId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -240,7 +242,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_InvalidId() public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_InvalidId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -254,7 +256,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_NotIntId() public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_NotIntId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -268,7 +270,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByPrice_FloatContraintForOptionalPrice_Valid() public async Task GetProductByPrice_FloatContraintForOptionalPrice_Valid()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -286,7 +288,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByPrice_FloatContraintForOptionalPrice_NoPrice() public async Task GetProductByPrice_FloatContraintForOptionalPrice_NoPrice()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -303,7 +305,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByManufacturerId_IntMin10Constraint_ForOptionalManufacturerId_Valid() public async Task GetProductByManufacturerId_IntMin10Constraint_ForOptionalManufacturerId_Valid()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -321,7 +323,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetProductByManufacturerId_IntMin10Cinstraint_ForOptionalManufacturerId_NoId() public async Task GetProductByManufacturerId_IntMin10Cinstraint_ForOptionalManufacturerId_NoId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -338,7 +340,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetUserByName_RegExConstraint_ForMandatoryName_Valid() public async Task GetUserByName_RegExConstraint_ForMandatoryName_Valid()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -356,7 +358,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetUserByName_RegExConstraint_ForMandatoryName_InValid() public async Task GetUserByName_RegExConstraint_ForMandatoryName_InValid()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -370,7 +372,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetStoreById_GuidConstraintForOptionalId_Valid() public async Task GetStoreById_GuidConstraintForOptionalId_Valid()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -389,7 +391,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetStoreById_GuidConstraintForOptionalId_NoId() public async Task GetStoreById_GuidConstraintForOptionalId_NoId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -406,7 +408,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetStoreById_GuidConstraintForOptionalId_NotGuidId() public async Task GetStoreById_GuidConstraintForOptionalId_NotGuidId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -420,7 +422,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_Valid() public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_Valid()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -438,7 +440,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_MoreLength() public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_MoreLength()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -452,7 +454,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_LessLength() public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_LessLength()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -466,7 +468,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_NoAlpha() public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_NoAlpha()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -623,7 +625,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string expectedLink) string expectedLink)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -8,6 +8,7 @@ using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -17,12 +18,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FormatterWebSite); private const string SiteName = nameof(FormatterWebSite);
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FormatterWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task CheckIfXmlInputFormatterIsBeingCalled() public async Task CheckIfXmlInputFormatterIsBeingCalled()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var sampleInputInt = 10; var sampleInputInt = 10;
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
@ -47,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonInputFormatter_IsSelectedForJsonRequest(string requestContentType) public async Task JsonInputFormatter_IsSelectedForJsonRequest(string requestContentType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var sampleInputInt = 10; var sampleInputInt = 10;
var input = "{\"SampleInt\":10}"; var input = "{\"SampleInt\":10}";
@ -79,7 +82,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var actionName = filterHandlesModelStateError ? "ActionFilterHandlesError" : "ActionHandlesError"; var actionName = filterHandlesModelStateError ? "ActionFilterHandlesError" : "ActionHandlesError";
var expectedSource = filterHandlesModelStateError ? "filter" : "action"; var expectedSource = filterHandlesModelStateError ? "filter" : "action";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{\"SampleInt\":10}"; var input = "{\"SampleInt\":10}";
var content = new StringContent(input); var content = new StringContent(input);
@ -110,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonInputFormatter_IsModelStateValid_ForValidContentType(string requestContentType, string jsonInput, int expectedSampleIntValue) public async Task JsonInputFormatter_IsModelStateValid_ForValidContentType(string requestContentType, string jsonInput, int expectedSampleIntValue)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType); var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType);
@ -130,7 +133,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonInputFormatter_IsModelStateInvalid_ForEmptyContentType(string jsonInput) public async Task JsonInputFormatter_IsModelStateInvalid_ForEmptyContentType(string jsonInput)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent(jsonInput, Encoding.UTF8, "application/json"); var content = new StringContent(jsonInput, Encoding.UTF8, "application/json");
content.Headers.Clear(); content.Headers.Clear();
@ -149,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonInputFormatter_IsModelStateValid_ForTransferEncodingChunk(string requestContentType, string jsonInput, int expectedSampleIntValue) public async Task JsonInputFormatter_IsModelStateValid_ForTransferEncodingChunk(string requestContentType, string jsonInput, int expectedSampleIntValue)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType); var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType);
client.DefaultRequestHeaders.TransferEncodingChunked = true; client.DefaultRequestHeaders.TransferEncodingChunked = true;
@ -169,7 +172,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CustomFormatter_IsSelected_ForSupportedContentTypeAndEncoding(string encoding) public async Task CustomFormatter_IsSelected_ForSupportedContentTypeAndEncoding(string encoding)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent("Test Content", Encoding.GetEncoding(encoding), "text/plain"); var content = new StringContent("Test Content", Encoding.GetEncoding(encoding), "text/plain");
@ -188,7 +191,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CustomFormatter_NotSelected_ForUnsupportedContentType(string contentType) public async Task CustomFormatter_NotSelected_ForUnsupportedContentType(string contentType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent("Test Content", Encoding.UTF8, contentType); var content = new StringContent("Test Content", Encoding.UTF8, contentType);

View File

@ -10,6 +10,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.WebUtilities; using Microsoft.AspNet.WebUtilities;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -19,6 +20,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FormatterWebSite); private const string SiteName = nameof(FormatterWebSite);
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FormatterWebSite.Startup().ConfigureServices;
// Parameters: Request Content, Expected status code, Expected model state error message // Parameters: Request Content, Expected status code, Expected model state error message
public static IEnumerable<object[]> SimpleTypePropertiesModelRequestData public static IEnumerable<object[]> SimpleTypePropertiesModelRequestData
@ -46,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CheckIfObjectIsDeserializedWithoutErrors() public async Task CheckIfObjectIsDeserializedWithoutErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var sampleId = 2; var sampleId = 2;
var sampleName = "SampleUser"; var sampleName = "SampleUser";
@ -73,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CheckIfObjectIsDeserialized_WithErrors() public async Task CheckIfObjectIsDeserialized_WithErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var sampleId = 0; var sampleId = 0;
var sampleName = "user"; var sampleName = "user";
@ -100,7 +102,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CheckIfExcludedFieldsAreNotValidated() public async Task CheckIfExcludedFieldsAreNotValidated()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent("{\"Alias\":\"xyz\"}", Encoding.UTF8, "application/json"); var content = new StringContent("{\"Alias\":\"xyz\"}", Encoding.UTF8, "application/json");
@ -117,7 +119,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ShallowValidation_HappensOnExcluded_ComplexTypeProperties() public async Task ShallowValidation_HappensOnExcluded_ComplexTypeProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var requestData = "{\"Name\":\"Library Manager\", \"Suppliers\": [{\"Name\":\"Contoso Corp\"}]}"; var requestData = "{\"Name\":\"Library Manager\", \"Suppliers\": [{\"Name\":\"Contoso Corp\"}]}";
var content = new StringContent(requestData, Encoding.UTF8, "application/json"); var content = new StringContent(requestData, Encoding.UTF8, "application/json");
@ -150,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string expectedModelStateErrorMessage) string expectedModelStateErrorMessage)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent(requestContent, Encoding.UTF8, "application/json"); var content = new StringContent(requestContent, Encoding.UTF8, "application/json");
@ -172,7 +174,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CheckIfExcludedField_IsValidatedForNonBodyBoundModels() public async Task CheckIfExcludedField_IsValidatedForNonBodyBoundModels()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var kvps = new List<KeyValuePair<string, string>>(); var kvps = new List<KeyValuePair<string, string>>();
kvps.Add(new KeyValuePair<string, string>("Alias", "xyz")); kvps.Add(new KeyValuePair<string, string>("Alias", "xyz"));

View File

@ -8,6 +8,7 @@ using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -17,6 +18,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FormatterWebSite); private const string SiteName = nameof(FormatterWebSite);
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FormatterWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task JsonOutputFormatter_ReturnsIndentedJson() public async Task JsonOutputFormatter_ReturnsIndentedJson()
@ -35,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
serializerSettings.Formatting = Formatting.Indented; serializerSettings.Formatting = Formatting.Indented;
var expectedBody = JsonConvert.SerializeObject(user, serializerSettings); var expectedBody = JsonConvert.SerializeObject(user, serializerSettings);
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -50,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SerializableErrorIsReturnedInExpectedFormat() public async Task SerializableErrorIsReturnedInExpectedFormat()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -14,6 +15,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(BasicWebSite); private const string SiteName = nameof(BasicWebSite);
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new BasicWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("application/json")] [InlineData("application/json")]
@ -21,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_Conneg(string mediaType) public async Task JsonResult_Conneg(string mediaType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/JsonResult/Plain"; var url = "http://localhost/JsonResult/Plain";
@ -47,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_Conneg_Fails(string mediaType) public async Task JsonResult_Conneg_Fails(string mediaType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/JsonResult/Plain"; var url = "http://localhost/JsonResult/Plain";
@ -70,7 +72,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_Null() public async Task JsonResult_Null()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/JsonResult/Null"; var url = "http://localhost/JsonResult/Null";
@ -92,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_String() public async Task JsonResult_String()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/JsonResult/String"; var url = "http://localhost/JsonResult/String";
@ -115,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_CustomFormatter_Conneg(string mediaType) public async Task JsonResult_CustomFormatter_Conneg(string mediaType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/JsonResult/CustomFormatter"; var url = "http://localhost/JsonResult/CustomFormatter";
@ -141,7 +143,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_CustomFormatter_Conneg_Fails(string mediaType) public async Task JsonResult_CustomFormatter_Conneg_Fails(string mediaType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/JsonResult/CustomFormatter"; var url = "http://localhost/JsonResult/CustomFormatter";
@ -163,7 +165,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonResult_CustomContentType() public async Task JsonResult_CustomContentType()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/JsonResult/CustomContentType"; var url = "http://localhost/JsonResult/CustomContentType";

View File

@ -7,6 +7,7 @@ using System.Net.Http.Headers;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,6 +16,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(BasicWebSite); private const string SiteName = nameof(BasicWebSite);
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new BasicWebSite.Startup().ConfigureServices;
// Some tests require comparing the actual response body against an expected response baseline // Some tests require comparing the actual response body against an expected response baseline
// so they require a reference to the assembly on which the resources are located, in order to // so they require a reference to the assembly on which the resources are located, in order to
@ -28,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GeneratedLinksWithActionResults_AreRelativeLinks_WhenSetOnLocationHeader(string url) public async Task GeneratedLinksWithActionResults_AreRelativeLinks_WhenSetOnLocationHeader(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -47,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GeneratedLinks_AreNotPunyEncoded_WhenGeneratedOnViews() public async Task GeneratedLinks_AreNotPunyEncoded_WhenGeneratedOnViews()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8"); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");

View File

@ -11,6 +11,7 @@ using System.Threading.Tasks;
using LoggingWebSite; using LoggingWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Logging; using Microsoft.AspNet.Mvc.Logging;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -20,12 +21,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(LoggingWebSite); private const string SiteName = nameof(LoggingWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task Successful_ActionSelection_Logged() public async Task Successful_ActionSelection_Logged()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var requestTraceId = Guid.NewGuid().ToString(); var requestTraceId = Guid.NewGuid().ToString();
@ -60,7 +62,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task Failed_ActionSelection_Logged() public async Task Failed_ActionSelection_Logged()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var requestTraceId = Guid.NewGuid().ToString(); var requestTraceId = Guid.NewGuid().ToString();

View File

@ -11,6 +11,7 @@ using LoggingWebSite.Controllers;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.Logging; using Microsoft.AspNet.Mvc.Logging;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -20,6 +21,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(LoggingWebSite); private const string SiteName = nameof(LoggingWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task AssemblyValues_LoggedAtStartup() public async Task AssemblyValues_LoggedAtStartup()
@ -87,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
private async Task<IEnumerable<LogInfoDto>> GetLogsByDataTypeAsync<T>() private async Task<IEnumerable<LogInfoDto>> GetLogsByDataTypeAsync<T>()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetStringAsync("http://localhost/logs"); var response = await client.GetStringAsync("http://localhost/logs");

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ModelBindingWebSite; using ModelBindingWebSite;
using ModelBindingWebSite.Controllers; using ModelBindingWebSite.Controllers;
using ModelBindingWebSite.Models; using ModelBindingWebSite.Models;
@ -18,12 +19,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ModelBindingWebSite); private const string SiteName = nameof(ModelBindingWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task FromForm_CustomModelPrefix_ForParameter() public async Task FromForm_CustomModelPrefix_ForParameter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FromFormAttribute_Company/CreateCompany"; var url = "http://localhost/FromFormAttribute_Company/CreateCompany";
@ -51,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromForm_CustomModelPrefix_ForCollectionParameter() public async Task FromForm_CustomModelPrefix_ForCollectionParameter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FromFormAttribute_Company/CreateCompanyFromEmployees"; var url = "http://localhost/FromFormAttribute_Company/CreateCompanyFromEmployees";
@ -77,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromForm_CustomModelPrefix_ForProperty() public async Task FromForm_CustomModelPrefix_ForProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FromFormAttribute_Company/CreateCompany"; var url = "http://localhost/FromFormAttribute_Company/CreateCompany";
@ -103,7 +105,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromForm_CustomModelPrefix_ForCollectionProperty() public async Task FromForm_CustomModelPrefix_ForCollectionProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FromFormAttribute_Company/CreateDepartment"; var url = "http://localhost/FromFormAttribute_Company/CreateDepartment";
@ -130,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromForm_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix() public async Task FromForm_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FromFormAttribute_Company/ValidateDepartment"; var url = "http://localhost/FromFormAttribute_Company/ValidateDepartment";

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -15,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ModelBindingWebSite); private const string SiteName = nameof(ModelBindingWebSite);
private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ModelBindingWebSite.Startup().ConfigureServices;
// The action that this test hits will echo back the model-bound value // The action that this test hits will echo back the model-bound value
[Theory] [Theory]
@ -26,7 +28,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expected = headerValue; var expected = headerValue;
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter");
@ -50,7 +52,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var title = "How to make really really good soup."; var title = "How to make really really good soup.";
var tags = new string[] { "Cooking", "Recipes", "Awesome" }; var tags = new string[] { "Cooking", "Recipes", "Awesome" };
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName");
@ -76,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var tags = new string[] { "Cooking", "Recipes", "Awesome" }; var tags = new string[] { "Cooking", "Recipes", "Awesome" };
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName");
@ -99,7 +101,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromHeader_NonExistingHeaderAddsValidationErrors_OnCollectionProperty_CustomName() public async Task FromHeader_NonExistingHeaderAddsValidationErrors_OnCollectionProperty_CustomName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName");
@ -125,7 +127,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expected = "1e331f25-0869-4c87-8a94-64e6e40cb5a0"; var expected = "1e331f25-0869-4c87-8a94-64e6e40cb5a0";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter/CustomName"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter/CustomName");
@ -153,7 +155,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expected = headerValue; var expected = headerValue;
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter");
@ -181,7 +183,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string headerValue) string headerValue)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -212,7 +214,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expected = headerValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var expected = headerValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringArrayParameter"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringArrayParameter");
@ -240,7 +242,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var title = "How to make really really good soup."; var title = "How to make really really good soup.";
var tags = new string[] { "Cooking", "Recipes", "Awesome" }; var tags = new string[] { "Cooking", "Recipes", "Awesome" };
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToModel?author=Marvin"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToModel?author=Marvin");
@ -268,7 +270,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromHeader_BindHeader_ToModel_NoValues_ValidationError() public async Task FromHeader_BindHeader_ToModel_NoValues_ValidationError()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToModel?author=Marvin"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToModel?author=Marvin");
@ -298,7 +300,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromHeader_BindHeader_ToModel_NoValues_InitializedValue_ValidationError() public async Task FromHeader_BindHeader_ToModel_NoValues_InitializedValue_ValidationError()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -330,7 +332,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromHeader_BindHeader_ToModel_NoValues_DefaultValue_NoValidationError() public async Task FromHeader_BindHeader_ToModel_NoValues_DefaultValue_NoValidationError()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ModelBindingWebSite; using ModelBindingWebSite;
using ModelBindingWebSite.Controllers; using ModelBindingWebSite.Controllers;
using ModelBindingWebSite.Models; using ModelBindingWebSite.Models;
@ -16,12 +17,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ModelBindingWebSite); private const string SiteName = nameof(ModelBindingWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task FromQuery_CustomModelPrefix_ForParameter() public async Task FromQuery_CustomModelPrefix_ForParameter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// [FromQuery(Name = "customPrefix")] is used to apply a prefix // [FromQuery(Name = "customPrefix")] is used to apply a prefix
@ -43,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromQuery_CustomModelPrefix_ForCollectionParameter() public async Task FromQuery_CustomModelPrefix_ForCollectionParameter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =
@ -64,7 +66,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromQuery_CustomModelPrefix_ForProperty() public async Task FromQuery_CustomModelPrefix_ForProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// [FromQuery(Name = "EmployeeId")] is used to apply a prefix // [FromQuery(Name = "EmployeeId")] is used to apply a prefix
@ -87,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromQuery_CustomModelPrefix_ForCollectionProperty() public async Task FromQuery_CustomModelPrefix_ForCollectionProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =
@ -110,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromQuery_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix() public async Task FromQuery_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ModelBindingWebSite; using ModelBindingWebSite;
using ModelBindingWebSite.Models; using ModelBindingWebSite.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -17,12 +18,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ModelBindingWebSite); private const string SiteName = nameof(ModelBindingWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task FromRoute_CustomModelPrefix_ForParameter() public async Task FromRoute_CustomModelPrefix_ForParameter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// [FromRoute(Name = "customPrefix")] is used to apply a prefix // [FromRoute(Name = "customPrefix")] is used to apply a prefix
@ -42,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromRoute_CustomModelPrefix_ForProperty() public async Task FromRoute_CustomModelPrefix_ForProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// [FromRoute(Name = "EmployeeId")] is used to apply a prefix // [FromRoute(Name = "EmployeeId")] is used to apply a prefix
@ -63,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FromRoute_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix() public async Task FromRoute_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// [FromRoute(Name = "TestEmployees")] is used to apply a prefix // [FromRoute(Name = "TestEmployees")] is used to apply a prefix

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ModelBindingWebSite.Models; using ModelBindingWebSite.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -14,12 +15,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ModelBindingWebSite); private const string SiteName = nameof(ModelBindingWebSite);
private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ModelBindingWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ModelBinderAttribute_CustomModelPrefix() public async Task ModelBinderAttribute_CustomModelPrefix()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// [ModelBinder(Name = "customPrefix")] is used to apply a prefix // [ModelBinder(Name = "customPrefix")] is used to apply a prefix
@ -41,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBinderAttribute_CustomModelPrefix_OnProperty() public async Task ModelBinderAttribute_CustomModelPrefix_OnProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =
@ -64,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBinderAttribute_WithPrefixOnParameter(string action) public async Task ModelBinderAttribute_WithPrefixOnParameter(string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// [ModelBinder(Name = "customPrefix")] is used to apply a prefix // [ModelBinder(Name = "customPrefix")] is used to apply a prefix
@ -89,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBinderAttribute_WithBinderOnParameter(string action) public async Task ModelBinderAttribute_WithBinderOnParameter(string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =
@ -111,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBinderAttribute_WithBinderOnEnum() public async Task ModelBinderAttribute_WithBinderOnEnum()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =

View File

@ -11,6 +11,7 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ModelBindingWebSite.Models; using ModelBindingWebSite.Models;
using ModelBindingWebSite.ViewModels; using ModelBindingWebSite.ViewModels;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -22,12 +23,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ModelBindingWebSite); private const string SiteName = nameof(ModelBindingWebSite);
private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ModelBindingWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task TypeBasedExclusion_ForBodyAndNonBodyBoundModels() public async Task TypeBasedExclusion_ForBodyAndNonBodyBoundModels()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Make sure the body object gets created with an invalid zip. // Make sure the body object gets created with an invalid zip.
@ -49,7 +51,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelValidation_DoesNotValidate_AnAlreadyValidatedObject() public async Task ModelValidation_DoesNotValidate_AnAlreadyValidatedObject()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -69,7 +71,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CompositeModelBinder_Restricts_ValueProviders(string actionName, string expectedValue) public async Task CompositeModelBinder_Restricts_ValueProviders(string actionName, string expectedValue)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Provide all three values, it should bind based on the attribute on the action method. // Provide all three values, it should bind based on the attribute on the action method.
@ -94,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_WithAPropertyFromBody() public async Task TryUpdateModel_WithAPropertyFromBody()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// the name would be of customer.Department.Name // the name would be of customer.Department.Name
@ -120,7 +122,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanModelBindServiceToAnArgument() public async Task CanModelBindServiceToAnArgument()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -134,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task CanModelBindServiceToAProperty() public async Task CanModelBindServiceToAProperty()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -149,7 +151,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task CanModelBindServiceToAProperty_OnBaseType() public async Task CanModelBindServiceToAProperty_OnBaseType()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -165,7 +167,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MultipleParametersMarkedWithFromBody_Throws() public async Task MultipleParametersMarkedWithFromBody_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -183,7 +185,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MultipleParameterAndPropertiesMarkedWithFromBody_Throws() public async Task MultipleParameterAndPropertiesMarkedWithFromBody_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -201,7 +203,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MultipleParametersMarkedWith_FromFormAndFromBody_Throws() public async Task MultipleParametersMarkedWith_FromFormAndFromBody_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -219,7 +221,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MultipleParameterAndPropertiesMarkedWith_FromFormAndFromBody_Throws() public async Task MultipleParameterAndPropertiesMarkedWith_FromFormAndFromBody_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -237,7 +239,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanBind_MultipleParameters_UsingFromForm() public async Task CanBind_MultipleParameters_UsingFromForm()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, var request = new HttpRequestMessage(HttpMethod.Post,
@ -275,7 +277,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanBind_MultipleProperties_UsingFromForm() public async Task CanBind_MultipleProperties_UsingFromForm()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, var request = new HttpRequestMessage(HttpMethod.Post,
@ -313,7 +315,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanBind_ComplexData_OnParameters_UsingFromAttributes() public async Task CanBind_ComplexData_OnParameters_UsingFromAttributes()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Provide all three values, it should bind based on the attribute on the action method. // Provide all three values, it should bind based on the attribute on the action method.
@ -357,7 +359,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanBind_ComplexData_OnProperties_UsingFromAttributes() public async Task CanBind_ComplexData_OnProperties_UsingFromAttributes()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Provide all three values, it should bind based on the attribute on the action method. // Provide all three values, it should bind based on the attribute on the action method.
@ -401,7 +403,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanBind_ComplexData_OnProperties_UsingFromAttributes_WithBody() public async Task CanBind_ComplexData_OnProperties_UsingFromAttributes_WithBody()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Provide all three values, it should bind based on the attribute on the action method. // Provide all three values, it should bind based on the attribute on the action method.
@ -441,7 +443,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NonExistingModelBinder_ForABinderMetadata_DoesNotRecurseInfinitely() public async Task NonExistingModelBinder_ForABinderMetadata_DoesNotRecurseInfinitely()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act & Assert // Act & Assert
@ -459,7 +461,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ParametersWithNoValueProviderMetadataUseTheAvailableValueProviders() public async Task ParametersWithNoValueProviderMetadataUseTheAvailableValueProviders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -481,7 +483,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ParametersAreAlwaysCreated_IfValuesAreProvidedWithoutModelName() public async Task ParametersAreAlwaysCreated_IfValuesAreProvidedWithoutModelName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -503,7 +505,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ParametersAreAlwaysCreated_IfValueIsProvidedForModelName() public async Task ParametersAreAlwaysCreated_IfValueIsProvidedForModelName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -524,7 +526,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ParametersAreAlwaysCreated_IfNoValuesAreProvided() public async Task ParametersAreAlwaysCreated_IfNoValuesAreProvided()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -545,7 +547,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PropertiesAreBound_IfTheyAreProvidedByValueProviders() public async Task PropertiesAreBound_IfTheyAreProvidedByValueProviders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -567,7 +569,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PropertiesAreBound_IfTheyAreMarkedExplicitly() public async Task PropertiesAreBound_IfTheyAreMarkedExplicitly()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -588,7 +590,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PropertiesAreBound_IfTheyArePocoMetadataMarkedTypes() public async Task PropertiesAreBound_IfTheyArePocoMetadataMarkedTypes()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -613,7 +615,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PropertiesAreNotBound_ByDefault() public async Task PropertiesAreNotBound_ByDefault()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -635,7 +637,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanBind_ComplexData_FromRouteData(string url) public async Task CanBind_ComplexData_FromRouteData(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -658,7 +660,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBindCancellationTokenParameteres() public async Task ModelBindCancellationTokenParameteres()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -673,7 +675,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBindCancellationToken_ForProperties() public async Task ModelBindCancellationToken_ForProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -689,7 +691,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBindingBindsBase64StringsToByteArrays() public async Task ModelBindingBindsBase64StringsToByteArrays()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -704,7 +706,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBindingBindsEmptyStringsToByteArrays() public async Task ModelBindingBindsEmptyStringsToByteArrays()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -719,7 +721,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBinding_LimitsErrorsToMaxErrorCount() public async Task ModelBinding_LimitsErrorsToMaxErrorCount()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var queryString = string.Join("=&", Enumerable.Range(0, 10).Select(i => "field" + i)); var queryString = string.Join("=&", Enumerable.Range(0, 10).Select(i => "field" + i));
@ -744,7 +746,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelBinding_ValidatesAllPropertiesInModel() public async Task ModelBinding_ValidatesAllPropertiesInModel()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -762,7 +764,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_Filters_UsingDefaultPropertyFilterProvider_WithExpressions() public async Task BindAttribute_Filters_UsingDefaultPropertyFilterProvider_WithExpressions()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -785,7 +787,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_Filters_UsingPropertyFilterProvider_UsingServices() public async Task BindAttribute_Filters_UsingPropertyFilterProvider_UsingServices()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -808,7 +810,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_Filters_UsingDefaultPropertyFilterProvider_WithPredicate() public async Task BindAttribute_Filters_UsingDefaultPropertyFilterProvider_WithPredicate()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -827,7 +829,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_BlacklistedAtEitherLevelIsNotBound() public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_BlacklistedAtEitherLevelIsNotBound()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -846,7 +848,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_IncludedAtBothLevelsIsBound() public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_IncludedAtBothLevelsIsBound()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -864,7 +866,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_IncludingAtOneLevelIsNotBound() public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_IncludingAtOneLevelIsNotBound()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -883,7 +885,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_BindsUsingParameterPrefix() public async Task BindAttribute_BindsUsingParameterPrefix()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -899,7 +901,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_DoesNotUseTypePrefix() public async Task BindAttribute_DoesNotUseTypePrefix()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -915,7 +917,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_FallsBackOnEmptyPrefixIfNoParameterPrefixIsProvided() public async Task BindAttribute_FallsBackOnEmptyPrefixIfNoParameterPrefixIsProvided()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -931,7 +933,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindAttribute_DoesNotFallBackOnEmptyPrefixIfParameterPrefixIsProvided() public async Task BindAttribute_DoesNotFallBackOnEmptyPrefixIfParameterPrefixIsProvided()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -948,7 +950,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_IncludeTopLevelProperty_IncludesAllSubProperties() public async Task TryUpdateModel_IncludeTopLevelProperty_IncludesAllSubProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -977,7 +979,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_ChainedPropertyExpression_Throws() public async Task TryUpdateModel_ChainedPropertyExpression_Throws()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
Expression<Func<User, object>> expression = model => model.Address.Country; Expression<Func<User, object>> expression = model => model.Address.Country;
@ -999,7 +1001,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_FailsToUpdateProperties() public async Task TryUpdateModel_FailsToUpdateProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1018,7 +1020,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_IncludeExpression_WorksOnlyAtTopLevel() public async Task TryUpdateModel_IncludeExpression_WorksOnlyAtTopLevel()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1041,7 +1043,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_Validates_ForTopLevelNotIncludedProperties() public async Task TryUpdateModel_Validates_ForTopLevelNotIncludedProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1058,7 +1060,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModelExcludeSpecific_Properties() public async Task TryUpdateModelExcludeSpecific_Properties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1081,7 +1083,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModelIncludeSpecific_Properties() public async Task TryUpdateModelIncludeSpecific_Properties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1104,7 +1106,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModelIncludesAllProperties_ByDefault() public async Task TryUpdateModelIncludesAllProperties_ByDefault()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1127,7 +1129,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task UpdateVehicle_WithJson_ProducesModelStateErrors() public async Task UpdateVehicle_WithJson_ProducesModelStateErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new var content = new
{ {
@ -1163,7 +1165,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task UpdateVehicle_WithJson_DoesPropertyValidationPriorToValidationAtType() public async Task UpdateVehicle_WithJson_DoesPropertyValidationPriorToValidationAtType()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new var content = new
{ {
@ -1197,7 +1199,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task UpdateVehicle_WithJson_BindsBodyAndServices() public async Task UpdateVehicle_WithJson_BindsBodyAndServices()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var trackingId = Guid.NewGuid().ToString(); var trackingId = Guid.NewGuid().ToString();
var postedContent = new var postedContent = new
@ -1234,7 +1236,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task UpdateVehicle_WithXml_BindsBodyServicesAndHeaders() public async Task UpdateVehicle_WithXml_BindsBodyServicesAndHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var trackingId = Guid.NewGuid().ToString(); var trackingId = Guid.NewGuid().ToString();
var postedContent = new VehicleViewModel var postedContent = new VehicleViewModel
@ -1274,7 +1276,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync( var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
"compiler/resources/UpdateDealerVehicle_PopulatesPropertyErrorsInViews.txt"); "compiler/resources/UpdateDealerVehicle_PopulatesPropertyErrorsInViews.txt");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var postedContent = new var postedContent = new
{ {
@ -1305,7 +1307,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync( var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
"compiler/resources/UpdateDealerVehicle_PopulatesValidationSummary.txt"); "compiler/resources/UpdateDealerVehicle_PopulatesValidationSummary.txt");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var postedContent = new var postedContent = new
{ {
@ -1336,7 +1338,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync( var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
"compiler/resources/UpdateDealerVehicle_UpdateSuccessful.txt"); "compiler/resources/UpdateDealerVehicle_UpdateSuccessful.txt");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var postedContent = new var postedContent = new
{ {
@ -1365,7 +1367,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormFileModelBinder_CanBind_SingleFile() public async Task FormFileModelBinder_CanBind_SingleFile()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FileUpload/UploadSingle"; var url = "http://localhost/FileUpload/UploadSingle";
var formData = new MultipartFormDataContent("Upload----"); var formData = new MultipartFormDataContent("Upload----");
@ -1386,7 +1388,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormFileModelBinder_CanBind_MultipleFiles() public async Task FormFileModelBinder_CanBind_MultipleFiles()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FileUpload/UploadMultiple"; var url = "http://localhost/FileUpload/UploadMultiple";
var formData = new MultipartFormDataContent("Upload----"); var formData = new MultipartFormDataContent("Upload----");
@ -1411,7 +1413,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormFileModelBinder_CanBind_MultipleListOfFiles() public async Task FormFileModelBinder_CanBind_MultipleListOfFiles()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FileUpload/UploadMultipleList"; var url = "http://localhost/FileUpload/UploadMultipleList";
var formData = new MultipartFormDataContent("Upload----"); var formData = new MultipartFormDataContent("Upload----");
@ -1446,7 +1448,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormFileModelBinder_CanBind_FileInsideModel() public async Task FormFileModelBinder_CanBind_FileInsideModel()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FileUpload/UploadModelWithFile"; var url = "http://localhost/FileUpload/UploadModelWithFile";
var formData = new MultipartFormDataContent("Upload----"); var formData = new MultipartFormDataContent("Upload----");
@ -1471,7 +1473,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_ReturnDerivedAndBaseProperties() public async Task TryUpdateModel_ReturnDerivedAndBaseProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1494,7 +1496,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync( var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
"compiler/resources/ModelBindingWebSite.Vehicle.Details.html"); "compiler/resources/ModelBindingWebSite.Vehicle.Details.html");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/vehicles/42"; var url = "http://localhost/vehicles/42";
@ -1514,7 +1516,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync( var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
"compiler/resources/ModelBindingWebSite.Vehicle.Edit.html"); "compiler/resources/ModelBindingWebSite.Vehicle.Edit.html");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/vehicles/42/edit"; var url = "http://localhost/vehicles/42/edit";
@ -1534,7 +1536,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync( var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
"compiler/resources/ModelBindingWebSite.Vehicle.Edit.Invalid.html"); "compiler/resources/ModelBindingWebSite.Vehicle.Edit.Invalid.html");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/vehicles/42/edit"; var url = "http://localhost/vehicles/42/edit";
var contentDictionary = new Dictionary<string, string> var contentDictionary = new Dictionary<string, string>
@ -1572,7 +1574,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/Home/GetErrorMessage"; var url = "http://localhost/Home/GetErrorMessage";
@ -1595,7 +1597,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task OverriddenMetadataProvider_CanChangeAdditionalValues() public async Task OverriddenMetadataProvider_CanChangeAdditionalValues()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/AdditionalValues"; var url = "http://localhost/AdditionalValues";
var expectedDictionary = new Dictionary<string, string> var expectedDictionary = new Dictionary<string, string>
@ -1618,7 +1620,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task OverriddenMetadataProvider_CanUseAttributesToChangeAdditionalValues() public async Task OverriddenMetadataProvider_CanUseAttributesToChangeAdditionalValues()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/GroupNames"; var url = "http://localhost/GroupNames";
var expectedDictionary = new Dictionary<string, string> var expectedDictionary = new Dictionary<string, string>
@ -1645,7 +1647,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModelNonGeneric_IncludesAllProperties_CanBind() public async Task TryUpdateModelNonGeneric_IncludesAllProperties_CanBind()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1668,7 +1670,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormCollectionModelBinder_CanBind_FormValues() public async Task FormCollectionModelBinder_CanBind_FormValues()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FormCollection/ReturnValuesAsList"; var url = "http://localhost/FormCollection/ReturnValuesAsList";
var nameValueCollection = new List<KeyValuePair<string, string>> var nameValueCollection = new List<KeyValuePair<string, string>>
@ -1692,7 +1694,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormCollectionModelBinder_CanBind_FormValuesWithDuplicateKeys() public async Task FormCollectionModelBinder_CanBind_FormValuesWithDuplicateKeys()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FormCollection/ReturnValuesAsList"; var url = "http://localhost/FormCollection/ReturnValuesAsList";
var nameValueCollection = new List<KeyValuePair<string, string>> var nameValueCollection = new List<KeyValuePair<string, string>>
@ -1717,7 +1719,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormCollectionModelBinder_CannotBind_NonFormValues() public async Task FormCollectionModelBinder_CannotBind_NonFormValues()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FormCollection/ReturnCollectionCount"; var url = "http://localhost/FormCollection/ReturnCollectionCount";
var data = new StringContent("Non form content"); var data = new StringContent("Non form content");
@ -1736,7 +1738,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormCollectionModelBinder_CanBind_FormWithFile() public async Task FormCollectionModelBinder_CanBind_FormWithFile()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/FormCollection/ReturnFileContent"; var url = "http://localhost/FormCollection/ReturnFileContent";
var expectedContent = "Test Content"; var expectedContent = "Test Content";
@ -1756,7 +1758,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModelNonGenericIncludesAllProperties_ByDefault() public async Task TryUpdateModelNonGenericIncludesAllProperties_ByDefault()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1822,7 +1824,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
IEnumerable<string> expectedModelStateErrorMessages) IEnumerable<string> expectedModelStateErrorMessages)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new StringContent(input, Encoding.UTF8, "text/json"); var content = new StringContent(input, Encoding.UTF8, "text/json");
@ -1848,7 +1850,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindModelAsync_WithCollection() public async Task BindModelAsync_WithCollection()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new Dictionary<string, string> var content = new Dictionary<string, string>
{ {
@ -1874,7 +1876,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindModelAsync_WithCollection_SpecifyingIndex() public async Task BindModelAsync_WithCollection_SpecifyingIndex()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new[] var content = new[]
{ {
@ -1900,7 +1902,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindModelAsync_WithNestedCollection() public async Task BindModelAsync_WithNestedCollection()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new Dictionary<string, string> var content = new Dictionary<string, string>
{ {
@ -1935,7 +1937,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindModelAsync_WithIncorrectlyFormattedNestedCollectionValue() public async Task BindModelAsync_WithIncorrectlyFormattedNestedCollectionValue()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new Dictionary<string, string> var content = new Dictionary<string, string>
{ {
@ -1958,7 +1960,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindModelAsync_WithNestedCollectionContainingRecursiveRelation() public async Task BindModelAsync_WithNestedCollectionContainingRecursiveRelation()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new Dictionary<string, string> var content = new Dictionary<string, string>
{ {
@ -1996,7 +1998,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindModelAsync_WithNestedCollectionContainingRecursiveRelation_WithMalformedValue() public async Task BindModelAsync_WithNestedCollectionContainingRecursiveRelation_WithMalformedValue()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new Dictionary<string, string> var content = new Dictionary<string, string>
{ {
@ -2023,7 +2025,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
bool expectedResult) bool expectedResult)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new List<KeyValuePair<string, string>> var content = new List<KeyValuePair<string, string>>
{ {
@ -2045,7 +2047,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task BindModelAsync_CheckBoxesList_BindSuccessful() public async Task BindModelAsync_CheckBoxesList_BindSuccessful()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var content = new List<KeyValuePair<string, string>> var content = new List<KeyValuePair<string, string>>
{ {
@ -2070,7 +2072,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryUpdateModel_ClearsModelStateEntries() public async Task TryUpdateModel_ClearsModelStateEntries()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/TryUpdateModel/TryUpdateModel_ClearsModelStateEntries"; var url = "http://localhost/TryUpdateModel/TryUpdateModel_ClearsModelStateEntries";

View File

@ -7,6 +7,7 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -16,12 +17,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ValidationWebSite); private const string SiteName = nameof(ValidationWebSite);
private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ValidationWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ModelMetaDataTypeAttribute_ValidBaseClass_EmptyResponseBody() public async Task ModelMetaDataTypeAttribute_ValidBaseClass_EmptyResponseBody()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Name\": \"MVC\", \"Contact\":\"4258959019\", \"Category\":\"Technology\"," + var input = "{ \"Name\": \"MVC\", \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 21, \"ProductDetails\": {\"Detail1\": \"d1\"," + "\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 21, \"ProductDetails\": {\"Detail1\": \"d1\"," +
@ -42,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelMetaDataTypeAttribute_InvalidPropertiesAndSubPropertiesOnBaseClass_ReturnsErrors() public async Task ModelMetaDataTypeAttribute_InvalidPropertiesAndSubPropertiesOnBaseClass_ReturnsErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Price\": 2, \"ProductDetails\": {\"Detail1\": \"d1\"}}"; var input = "{ \"Price\": 2, \"ProductDetails\": {\"Detail1\": \"d1\"}}";
var content = new StringContent(input, Encoding.UTF8, "application/json"); var content = new StringContent(input, Encoding.UTF8, "application/json");
@ -68,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelMetaDataTypeAttribute_InvalidComplexTypePropertyOnBaseClass_ReturnsErrors() public async Task ModelMetaDataTypeAttribute_InvalidComplexTypePropertyOnBaseClass_ReturnsErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Contact\":\"4255678765\", \"Category\":\"Technology\"," + var input = "{ \"Contact\":\"4255678765\", \"Category\":\"Technology\"," +
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 21 }"; "\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 21 }";
@ -90,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelMetaDataTypeAttribute_InvalidClassAttributeOnBaseClass_ReturnsErrors() public async Task ModelMetaDataTypeAttribute_InvalidClassAttributeOnBaseClass_ReturnsErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Contact\":\"4258959019\", \"Category\":\"Technology\"," + var input = "{ \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
"\"CompanyName\":\"Microsoft\", \"Country\":\"UK\",\"Price\": 21, \"ProductDetails\": {\"Detail1\": \"d1\"," + "\"CompanyName\":\"Microsoft\", \"Country\":\"UK\",\"Price\": 21, \"ProductDetails\": {\"Detail1\": \"d1\"," +
@ -114,7 +116,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelMetaDataTypeAttribute_ValidDerivedClass_EmptyResponseBody() public async Task ModelMetaDataTypeAttribute_ValidDerivedClass_EmptyResponseBody()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Name\": \"MVC\", \"Contact\":\"4258959019\", \"Category\":\"Technology\"," + var input = "{ \"Name\": \"MVC\", \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\", \"Version\":\"2\"," + "\"CompanyName\":\"Microsoft\", \"Country\":\"USA\", \"Version\":\"2\"," +
@ -135,7 +137,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelMetaDataTypeAttribute_InvalidPropertiesOnDerivedClass_ReturnsErrors() public async Task ModelMetaDataTypeAttribute_InvalidPropertiesOnDerivedClass_ReturnsErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Name\": \"MVC\", \"Contact\":\"425-895-9019\", \"Category\":\"Technology\"," + var input = "{ \"Name\": \"MVC\", \"Contact\":\"425-895-9019\", \"Category\":\"Technology\"," +
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 2}"; "\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 2}";
@ -158,7 +160,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelMetaDataTypeAttribute_InvalidClassAttributeOnBaseClassProduct_ReturnsErrors() public async Task ModelMetaDataTypeAttribute_InvalidClassAttributeOnBaseClassProduct_ReturnsErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Contact\":\"4258959019\", \"Category\":\"Technology\"," + var input = "{ \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
"\"CompanyName\":\"Microsoft\", \"Country\":\"UK\",\"Version\":\"2\"," + "\"CompanyName\":\"Microsoft\", \"Country\":\"UK\",\"Version\":\"2\"," +

View File

@ -10,6 +10,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -22,6 +23,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
private readonly static string SamplesFolder = Path.Combine("..", "..", "samples"); private readonly static string SamplesFolder = Path.Combine("..", "..", "samples");
private readonly Action<IApplicationBuilder> _app = new MvcSample.Web.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new MvcSample.Web.Startup().Configure;
private readonly Func<IServiceCollection, IServiceProvider> _configureServices = new MvcSample.Web.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("")] // Shared/MyView.cshtml [InlineData("")] // Shared/MyView.cshtml
@ -39,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task Home_Pages_ReturnSuccess(string path) public async Task Home_Pages_ReturnSuccess(string path)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder); var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -66,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormUrlEncoded_ReturnsAppropriateResults(string input, string expectedOutput) public async Task FormUrlEncoded_ReturnsAppropriateResults(string input, string expectedOutput)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder); var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/FormUrlEncoded/IsValidPerson"); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/FormUrlEncoded/IsValidPerson");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
@ -83,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FormUrlEncoded_Index_ReturnSuccess() public async Task FormUrlEncoded_Index_ReturnSuccess()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder); var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -98,7 +100,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task Home_NotFoundAction_Returns404() public async Task Home_NotFoundAction_Returns404()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder); var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -113,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task Home_CreateUser_ReturnsXmlBasedOnAcceptHeader() public async Task Home_CreateUser_ReturnsXmlBasedOnAcceptHeader()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder); var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/ReturnUser"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/ReturnUser");
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8"));
@ -141,7 +143,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FiltersController_Tests(string url, HttpStatusCode statusCode) public async Task FiltersController_Tests(string url, HttpStatusCode statusCode)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder); var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -156,7 +158,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task FiltersController_Crash_ThrowsException() public async Task FiltersController_Crash_ThrowsException()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder); var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -3,6 +3,7 @@
using System; using System;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -17,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expectedMessage = "Unable to find the required services. Please add all the required " + var expectedMessage = "Unable to find the required services. Please add all the required " +
"services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.UseServices(...)' " + "services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.ConfigureServices(...)' " +
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code."; "or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
// Act & Assert // Act & Assert

View File

@ -21,6 +21,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(MvcTagHelpersWebSite); private const string SiteName = nameof(MvcTagHelpersWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
private static readonly Assembly _resourcesAssembly = typeof(MvcTagHelpersTest).GetTypeInfo().Assembly; private static readonly Assembly _resourcesAssembly = typeof(MvcTagHelpersTest).GetTypeInfo().Assembly;
[Theory] [Theory]
@ -48,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task MvcTagHelpers_GeneratesExpectedResults(string action, string antiForgeryPath) public async Task MvcTagHelpers_GeneratesExpectedResults(string action, string antiForgeryPath)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8"); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
@ -79,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ValidationTagHelpers_GeneratesExpectedSpansAndDivs() public async Task ValidationTagHelpers_GeneratesExpectedSpansAndDivs()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync( var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
"compiler/resources/MvcTagHelpersWebSite.MvcTagHelper_Customer.Index.html"); "compiler/resources/MvcTagHelpersWebSite.MvcTagHelper_Customer.Index.html");
@ -113,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var assertFile = var assertFile =
"compiler/resources/CacheTagHelper_CanCachePortionsOfViewsPartialViewsAndViewComponents.Assert"; "compiler/resources/CacheTagHelper_CanCachePortionsOfViewsPartialViewsAndViewComponents.Assert";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost"); client.BaseAddress = new Uri("http://localhost");
client.DefaultRequestHeaders.Add("Locale", "North"); client.DefaultRequestHeaders.Add("Locale", "North");
@ -162,7 +163,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CacheTagHelper_ExpiresContent_BasedOnExpiresParameter() public async Task CacheTagHelper_ExpiresContent_BasedOnExpiresParameter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost"); client.BaseAddress = new Uri("http://localhost");
@ -186,7 +187,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CacheTagHelper_UsesVaryByCookie_ToVaryContent() public async Task CacheTagHelper_UsesVaryByCookie_ToVaryContent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost"); client.BaseAddress = new Uri("http://localhost");
@ -218,7 +219,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CacheTagHelper_VariesByRoute() public async Task CacheTagHelper_VariesByRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost"); client.BaseAddress = new Uri("http://localhost");
@ -274,7 +275,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CacheTagHelper_VariesByUserId() public async Task CacheTagHelper_VariesByUserId()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost"); client.BaseAddress = new Uri("http://localhost");
@ -301,7 +302,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CacheTagHelper_BubblesExpirationOfNestedTagHelpers() public async Task CacheTagHelper_BubblesExpirationOfNestedTagHelpers()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost"); client.BaseAddress = new Uri("http://localhost");
@ -346,7 +347,12 @@ Products: Laptops (3)";
// Arrange // Arrange
var newServices = new ServiceCollection(); var newServices = new ServiceCollection();
newServices.InitializeTagHelper<FormTagHelper>((helper, _) => helper.AntiForgery = optionsAntiForgery); newServices.InitializeTagHelper<FormTagHelper>((helper, _) => helper.AntiForgery = optionsAntiForgery);
var server = TestHelper.CreateServer(_app, SiteName, services => services.Add(newServices)); var server = TestHelper.CreateServer(_app, SiteName,
services =>
{
services.Add(newServices);
_configureServices(services);
});
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8"); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");

View File

@ -7,6 +7,7 @@ using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using ContentNegotiationWebSite; using ContentNegotiationWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ContentNegotiationWebSite); private const string SiteName = nameof(ContentNegotiationWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("ReturnTaskOfString")] [InlineData("ReturnTaskOfString")]
@ -24,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task StringOutputFormatter_ForStringValues_GetsSelectedReturnsTextPlainContentType(string actionName) public async Task StringOutputFormatter_ForStringValues_GetsSelectedReturnsTextPlainContentType(string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("text/plain;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("text/plain;charset=utf-8");
var expectedBody = actionName; var expectedBody = actionName;
@ -44,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task JsonOutputFormatter_ForNonStringValue_GetsSelected(string actionName) public async Task JsonOutputFormatter_ForNonStringValue_GetsSelected(string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
@ -61,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoContentFormatter_ForVoidAndTaskReturnType_GetsSelectedAndWritesResponse(string actionName) public async Task NoContentFormatter_ForVoidAndTaskReturnType_GetsSelectedAndWritesResponse(string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -83,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task NoContentFormatter_ForNullValue_ByDefault_GetsSelectedAndWritesResponse(string actionName) public async Task NoContentFormatter_ForNullValue_ByDefault_GetsSelectedAndWritesResponse(string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -106,7 +108,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
NoContentFormatter_ForNullValue_AndTreatNullAsNoContentFlagSetToFalse_DoesNotGetSelected(string actionName) NoContentFormatter_ForNullValue_AndTreatNullAsNoContentFlagSetToFalse_DoesNotGetSelected(string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -21,13 +21,18 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
private const string SiteName = nameof(PrecompilationWebSite); private const string SiteName = nameof(PrecompilationWebSite);
private static readonly TimeSpan _cacheDelayInterval = TimeSpan.FromSeconds(1); private static readonly TimeSpan _cacheDelayInterval = TimeSpan.FromSeconds(1);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task PrecompiledView_RendersCorrectly() public async Task PrecompiledView_RendersCorrectly()
{ {
// Arrange // Arrange
IServiceCollection serviceCollection = null; IServiceCollection serviceCollection = null;
var server = TestHelper.CreateServer(_app, SiteName, services => serviceCollection = services); var server = TestHelper.CreateServer(_app, SiteName, services =>
{
_configureServices(services);
serviceCollection = services;
});
var client = server.CreateClient(); var client = server.CreateClient();
var serviceProvider = serviceCollection.BuildServiceProvider(); var serviceProvider = serviceCollection.BuildServiceProvider();
@ -170,7 +175,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
@"Value set inside DNXCORE50 " + assemblyNamePrefix; @"Value set inside DNXCORE50 " + assemblyNamePrefix;
#endif #endif
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -187,7 +192,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var expected = GetAssemblyNamePrefix(); var expected = GetAssemblyNamePrefix();
IServiceCollection serviceCollection = null; IServiceCollection serviceCollection = null;
var server = TestHelper.CreateServer(_app, SiteName, services => serviceCollection = services); var server = TestHelper.CreateServer(_app, SiteName, services =>
{
_configureServices(services);
serviceCollection = services;
});
var client = server.CreateClient(); var client = server.CreateClient();
var serviceProvider = serviceCollection.BuildServiceProvider(); var serviceProvider = serviceCollection.BuildServiceProvider();
@ -229,7 +238,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
var expected = @"<root data-root=""true""><input class=""form-control"" type=""number"" data-val=""true""" + var expected = @"<root data-root=""true""><input class=""form-control"" type=""number"" data-val=""true""" +
@" data-val-range=""The field Age must be between 10 and 100."" data-val-range-max=""100"" "+ @" data-val-range=""The field Age must be between 10 and 100."" data-val-range-max=""100"" "+
@"data-val-range-min=""10"" id=""Age"" name=""Age"" value="""" /><a href="""">Back to List</a></root>"; @"data-val-range-min=""10"" id=""Age"" name=""Age"" value="""" /><a href="""">Back to List</a></root>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -247,7 +256,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange // Arrange
var assemblyNamePrefix = GetAssemblyNamePrefix(); var assemblyNamePrefix = GetAssemblyNamePrefix();
var expected = @"<root>root-content</root>"; var expected = @"<root>root-content</root>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -5,6 +5,7 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using RazorCompilerCacheWebSite; using RazorCompilerCacheWebSite;
using Xunit; using Xunit;
@ -14,12 +15,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RazorCompilerCacheWebSite); private const string SiteName = nameof(RazorCompilerCacheWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task CompilerCache_IsNotInitializedUntilFirstViewRequest() public async Task CompilerCache_IsNotInitializedUntilFirstViewRequest()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.BaseAddress = new Uri("http://localhost"); client.BaseAddress = new Uri("http://localhost");

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using RazorEmbeddedViewsWebSite; using RazorEmbeddedViewsWebSite;
using Xunit; using Xunit;
@ -13,13 +14,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RazorEmbeddedViewsWebSite); private const string SiteName = nameof(RazorEmbeddedViewsWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task RazorViewEngine_UsesFileProviderOnViewEngineOptionsToLocateViews() public async Task RazorViewEngine_UsesFileProviderOnViewEngineOptionsToLocateViews()
{ {
// Arrange // Arrange
var expectedMessage = "Hello test-user, this is /RazorEmbeddedViews_Home"; var expectedMessage = "Hello test-user, this is /RazorEmbeddedViews_Home";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -34,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expectedMessage = "Hello admin-user, this is /Restricted/RazorEmbeddedViews_Admin/Login"; var expectedMessage = "Hello admin-user, this is /Restricted/RazorEmbeddedViews_Admin/Login";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var target = "http://localhost/Restricted/RazorEmbeddedViews_Admin/Login?AdminUser=admin-user"; var target = "http://localhost/Restricted/RazorEmbeddedViews_Admin/Login?AdminUser=admin-user";

View File

@ -15,6 +15,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RazorPageExecutionInstrumentationWebSite); private const string SiteName = nameof(RazorPageExecutionInstrumentationWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
public static IEnumerable<object[]> InstrumentationData public static IEnumerable<object[]> InstrumentationData
{ {
@ -100,7 +101,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var context = new TestPageExecutionContext(); var context = new TestPageExecutionContext();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context)); var server = TestHelper.CreateServer(_app, SiteName, services =>
{
services.AddInstance(context);
_configureServices(services);
});
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -120,7 +125,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var context = new TestPageExecutionContext(); var context = new TestPageExecutionContext();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context)); var server = TestHelper.CreateServer(_app, SiteName, services =>
{
services.AddInstance(context);
_configureServices(services);
});
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Add("ENABLE-RAZOR-INSTRUMENTATION", "true"); client.DefaultRequestHeaders.Add("ENABLE-RAZOR-INSTRUMENTATION", "true");
@ -141,7 +150,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange - 1 // Arrange - 1
var context = new TestPageExecutionContext(); var context = new TestPageExecutionContext();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context)); var server = TestHelper.CreateServer(_app, SiteName, services =>
{
services.AddInstance(context);
_configureServices(services);
});
var client = server.CreateClient(); var client = server.CreateClient();
// Act - 1 // Act - 1
@ -183,7 +196,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
Tuple.Create(35, 8, true), Tuple.Create(35, 8, true),
}; };
var context = new TestPageExecutionContext(); var context = new TestPageExecutionContext();
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context)); var server = TestHelper.CreateServer(_app, SiteName, services =>
{
services.AddInstance(context);
_configureServices(services);
});
var client = server.CreateClient(); var client = server.CreateClient();
// Act - 1 // Act - 1

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using RazorWebSite; using RazorWebSite;
using Xunit; using Xunit;
@ -14,6 +15,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
private const string BaseUrl = "http://localhost/ViewNameSpecification_Home/"; private const string BaseUrl = "http://localhost/ViewNameSpecification_Home/";
private const string SiteName = nameof(RazorWebSite); private const string SiteName = nameof(RazorWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("LayoutSpecifiedWithPartialPathInViewStart")] [InlineData("LayoutSpecifiedWithPartialPathInViewStart")]
@ -26,7 +28,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
@"<layout> @"<layout>
_ViewStart that specifies partial Layout _ViewStart that specifies partial Layout
</layout>"; </layout>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -47,7 +49,7 @@ _ViewStart that specifies partial Layout
@"<non-shared> @"<non-shared>
Layout specified in page Layout specified in page
</non-shared>"; </non-shared>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -66,7 +68,7 @@ Layout specified in page
@"<non-shared> @"<non-shared>
Page With Non Partial Layout Page With Non Partial Layout
</non-shared>"; </non-shared>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -88,7 +90,7 @@ Page With Non Partial Layout
Non Shared Partial Non Shared Partial
</layout>"; </layout>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -8,6 +8,7 @@ using System.Net.Http;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -18,6 +19,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
private static readonly Assembly _resourcesAssembly = private static readonly Assembly _resourcesAssembly =
typeof(RemoteAttributeValidationTest).GetTypeInfo().Assembly; typeof(RemoteAttributeValidationTest).GetTypeInfo().Assembly;
private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ValidationWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("Aria", "/Aria")] [InlineData("Aria", "/Aria")]
@ -25,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RemoteAttribute_LeadsToExpectedValidationAttributes(string areaName, string pathSegment) public async Task RemoteAttribute_LeadsToExpectedValidationAttributes(string areaName, string pathSegment)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync( var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
"compiler/resources/ValidationWebSite." + areaName + ".RemoteAttribute_Home.Create.html"); "compiler/resources/ValidationWebSite." + areaName + ".RemoteAttribute_Home.Create.html");
@ -52,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string expectedContent) string expectedContent)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost" + pathSegment + var url = "http://localhost" + pathSegment +
"/RemoteAttribute_Verify/IsIdAvailable?UserId1=Joe1&UserId2=Joe2&UserId3=Joe3&UserId4=Joe4"; "/RemoteAttribute_Verify/IsIdAvailable?UserId1=Joe1&UserId2=Joe2&UserId3=Joe3&UserId4=Joe4";
@ -76,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string expectedContent) string expectedContent)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost" + pathSegment + "/RemoteAttribute_Verify/IsIdAvailable"; var url = "http://localhost" + pathSegment + "/RemoteAttribute_Verify/IsIdAvailable";
var contentDictionary = new Dictionary<string, string> var contentDictionary = new Dictionary<string, string>

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -16,6 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RequestServicesWebSite); private const string SiteName = nameof(RequestServicesWebSite);
private readonly Action<IApplicationBuilder> _app = new RequestServicesWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new RequestServicesWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new RequestServicesWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("http://localhost/RequestScoped/FromController")] [InlineData("http://localhost/RequestScoped/FromController")]
@ -27,7 +29,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RequestServices(string url) public async Task RequestServices(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act & Assert // Act & Assert
@ -48,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RequestServices_TagHelper() public async Task RequestServices_TagHelper()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/Other/FromTagHelper"; var url = "http://localhost/Other/FromTagHelper";
@ -73,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RequestServices_ActionConstraint() public async Task RequestServices_ActionConstraint()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/Other/FromActionConstraint"; var url = "http://localhost/Other/FromActionConstraint";

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -16,6 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FormatterWebSite); private const string SiteName = nameof(FormatterWebSite);
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FormatterWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("application/xml,*/*;0.2")] [InlineData("application/xml,*/*;0.2")]
@ -23,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AllMediaRangeAcceptHeader_FirstFormatterInListWritesResponse(string acceptHeader) public async Task AllMediaRangeAcceptHeader_FirstFormatterInListWritesResponse(string acceptHeader)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Add("Accept", acceptHeader); client.DefaultRequestHeaders.Add("Accept", acceptHeader);
@ -45,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AllMediaRangeAcceptHeader_ProducesAttributeIsHonored(string acceptHeader) public async Task AllMediaRangeAcceptHeader_ProducesAttributeIsHonored(string acceptHeader)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Add("Accept", acceptHeader); client.DefaultRequestHeaders.Add("Accept", acceptHeader);
var expectedResponseData = "<RespectBrowserAcceptHeaderController.Employee xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"" + var expectedResponseData = "<RespectBrowserAcceptHeaderController.Employee xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"" +
@ -70,7 +72,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AllMediaRangeAcceptHeader_WithContentTypeHeader_ContentTypeIsHonored(string acceptHeader) public async Task AllMediaRangeAcceptHeader_WithContentTypeHeader_ContentTypeIsHonored(string acceptHeader)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Add("Accept", acceptHeader); client.DefaultRequestHeaders.Add("Accept", acceptHeader);
var requestData = "<RespectBrowserAcceptHeaderController.Employee xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"" + var requestData = "<RespectBrowserAcceptHeaderController.Employee xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"" +

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ResponseCacheWebSite; using ResponseCacheWebSite;
using Xunit; using Xunit;
@ -14,12 +15,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ResponseCacheWebSite); private const string SiteName = nameof(ResponseCacheWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task ResponseCache_SetsAllHeaders() public async Task ResponseCache_SetsAllHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -48,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResponseCache_SetsDifferentCacheControlHeaders(string url, string expected) public async Task ResponseCache_SetsDifferentCacheControlHeaders(string url, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -63,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SetsHeadersForAllActionsOfClass() public async Task SetsHeadersForAllActionsOfClass()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -86,7 +88,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task HeadersSetInActionOverridesTheOnesInClass() public async Task HeadersSetInActionOverridesTheOnesInClass()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -101,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task HeadersToNotCacheAParticularAction() public async Task HeadersToNotCacheAParticularAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -116,7 +118,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ClassLevelHeadersAreUnsetByActionLevelHeaders() public async Task ClassLevelHeadersAreUnsetByActionLevelHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -136,7 +138,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task SetsCacheControlPublicByDefault() public async Task SetsCacheControlPublicByDefault()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -151,7 +153,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ThrowsWhenDurationIsNotSet() public async Task ThrowsWhenDurationIsNotSet()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act & Assert // Act & Assert
@ -167,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResponseCache_SetsAllHeaders_FromCacheProfile() public async Task ResponseCache_SetsAllHeaders_FromCacheProfile()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -182,7 +184,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResponseCache_SetsAllHeaders_ChosesTheRightProfile() public async Task ResponseCache_SetsAllHeaders_ChosesTheRightProfile()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -197,7 +199,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResponseCache_SetsNoCacheHeaders() public async Task ResponseCache_SetsNoCacheHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -214,7 +216,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResponseCache_AddsHeaders() public async Task ResponseCache_AddsHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -231,7 +233,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResponseCache_ModifiesHeaders() public async Task ResponseCache_ModifiesHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -246,7 +248,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ResponseCacheAttribute_OnAction_OverridesTheValuesOnClass() public async Task ResponseCacheAttribute_OnAction_OverridesTheValuesOnClass()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ModelBindingWebSite; using ModelBindingWebSite;
using ModelBindingWebSite.Models; using ModelBindingWebSite.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -25,6 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ModelBindingWebSite); private const string SiteName = nameof(ModelBindingWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
// Uses the expression p => p.Name // Uses the expression p => p.Name
[Fact] [Fact]
@ -32,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = "test-name"; var expected = "test-name";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -54,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = 40; var expected = 40;
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -76,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = 12; var expected = 12;
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -97,7 +99,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RoundTrippedValues_GetsModelBound_ForStringIndexedProperties() public async Task RoundTrippedValues_GetsModelBound_ForStringIndexedProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -114,7 +116,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var expected = "test-nested-name"; var expected = "test-nested-name";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -9,6 +9,7 @@ using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Routing; using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Routing.Template; using Microsoft.AspNet.Routing.Template;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -18,12 +19,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(BasicWebSite); private const string SiteName = nameof(BasicWebSite);
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new BasicWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task RouteData_Routers_ConventionalRoute() public async Task RouteData_Routers_ConventionalRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -48,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RouteData_Routers_AttributeRoute() public async Task RouteData_Routers_AttributeRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -78,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RouteData_DataTokens_FilterCanSetDataTokens() public async Task RouteData_DataTokens_FilterCanSetDataTokens()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync("http://localhost/Routing/DataTokens"); var response = await client.GetAsync("http://localhost/Routing/DataTokens");

View File

@ -5,6 +5,7 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// This website sets the generation of lowercase URLs to true // This website sets the generation of lowercase URLs to true
private readonly Action<IApplicationBuilder> _app = new LowercaseUrlsWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new LowercaseUrlsWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new LowercaseUrlsWebSite.Startup().ConfigureServices;
[Theory] [Theory]
// Generating lower case URL doesnt lowercase the query parameters // Generating lower case URL doesnt lowercase the query parameters
@ -34,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task GenerateLowerCaseUrlsTests(string path, string expectedUrl) public async Task GenerateLowerCaseUrlsTests(string path, string expectedUrl)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -9,6 +9,7 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Routing; using Microsoft.AspNet.Routing;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -18,12 +19,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RoutingWebSite); private const string SiteName = nameof(RoutingWebSite);
private readonly Action<IApplicationBuilder> _app = new RoutingWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new RoutingWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new RoutingWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ConventionRoutedController_ActionIsReachable() public async Task ConventionRoutedController_ActionIsReachable()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -51,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionRoutedController_ActionIsReachable_WithDefaults() public async Task ConventionRoutedController_ActionIsReachable_WithDefaults()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -79,7 +81,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionRoutedController_NonActionIsNotReachable() public async Task ConventionRoutedController_NonActionIsNotReachable()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -93,7 +95,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionRoutedController_InArea_ActionIsReachable() public async Task ConventionRoutedController_InArea_ActionIsReachable()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -122,7 +124,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionRoutedController_InArea_ActionBlockedByHttpMethod() public async Task ConventionRoutedController_InArea_ActionBlockedByHttpMethod()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -136,7 +138,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_IsReachable() public async Task AttributeRoutedAction_IsReachable()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -167,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_MultipleRouteAttributes_WorksWithNameAndOrder(string url) public async Task AttributeRoutedAction_MultipleRouteAttributes_WorksWithNameAndOrder(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -196,7 +198,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var url = "http://localhost/api/v2/Maps"; var url = "http://localhost/api/v2/Maps";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -224,7 +226,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
// Arrange // Arrange
var url = "http://localhost/api/v1/Maps"; var url = "http://localhost/api/v1/Maps";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -244,7 +246,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string method) string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -273,7 +275,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_MultipleHttpAttributesAndTokenReplacement(string url) public async Task AttributeRoutedAction_MultipleHttpAttributesAndTokenReplacement(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedUrl = new Uri(url).AbsolutePath; var expectedUrl = new Uri(url).AbsolutePath;
@ -307,7 +309,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string method) string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedUrl = new Uri(url).AbsolutePath; var expectedUrl = new Uri(url).AbsolutePath;
@ -323,7 +325,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_IsNotReachableWithTraditionalRoute() public async Task AttributeRoutedAction_IsNotReachableWithTraditionalRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -339,7 +341,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_TriedBeforeConventionRouting() public async Task AttributeRoutedAction_TriedBeforeConventionRouting()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -360,7 +362,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_ControllerLevelRoute_WithActionParameter_IsReachable() public async Task AttributeRoutedAction_ControllerLevelRoute_WithActionParameter_IsReachable()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -394,7 +396,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_ControllerLevelRoute_IsReachable() public async Task AttributeRoutedAction_ControllerLevelRoute_IsReachable()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -423,7 +425,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_RouteAttributeOnAction_IsReachable(string method) public async Task AttributeRoutedAction_RouteAttributeOnAction_IsReachable(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var message = new HttpRequestMessage(new HttpMethod(method), "http://localhost/Store/Shop/Orders"); var message = new HttpRequestMessage(new HttpMethod(method), "http://localhost/Store/Shop/Orders");
@ -450,7 +452,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_RouteAttributeOnActionAndController_IsReachable(string method) public async Task AttributeRoutedAction_RouteAttributeOnActionAndController_IsReachable(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var message = new HttpRequestMessage(new HttpMethod(method), "http://localhost/api/Employee/5/Salary"); var message = new HttpRequestMessage(new HttpMethod(method), "http://localhost/api/Employee/5/Salary");
@ -472,7 +474,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_RouteAttributeOnActionAndHttpGetOnDifferentAction_ReachesHttpGetAction() public async Task AttributeRoutedAction_RouteAttributeOnActionAndHttpGetOnDifferentAction_ReachesHttpGetAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var message = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Store/Shop/Orders"); var message = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Store/Shop/Orders");
@ -497,7 +499,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_ControllerLevelRoute_WithAcceptVerbs_IsReachable(string verb) public async Task AttributeRoutedAction_ControllerLevelRoute_WithAcceptVerbs_IsReachable(string verb)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -521,7 +523,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_ControllerLevelRoute_WithAcceptVerbsAndRouteTemplate_IsReachable(string verb) public async Task AttributeRoutedAction_ControllerLevelRoute_WithAcceptVerbsAndRouteTemplate_IsReachable(string verb)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -547,7 +549,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_AcceptVerbsAndRouteTemplate_IsReachable(string verb, string path) public async Task AttributeRoutedAction_AcceptVerbsAndRouteTemplate_IsReachable(string verb, string path)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedUrl = "/Bank"; var expectedUrl = "/Bank";
@ -570,7 +572,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_WithCustomHttpAttributes_IsReachable() public async Task AttributeRoutedAction_WithCustomHttpAttributes_IsReachable()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -596,7 +598,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_ControllerLevelRoute_CombinedWithActionRoute_IsReachable(string verb, string action) public async Task AttributeRoutedAction_ControllerLevelRoute_CombinedWithActionRoute_IsReachable(string verb, string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -622,7 +624,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_ActionLevelRouteWithTildeSlash_OverridesControllerLevelRoute() public async Task AttributeRoutedAction_ActionLevelRouteWithTildeSlash_OverridesControllerLevelRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -647,7 +649,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_OverrideActionOverridesOrderOnController() public async Task AttributeRoutedAction_OverrideActionOverridesOrderOnController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -672,7 +674,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_OrderOnActionOverridesOrderOnController() public async Task AttributeRoutedAction_OrderOnActionOverridesOrderOnController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -693,7 +695,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkGeneration_OverrideActionOverridesOrderOnController() public async Task AttributeRoutedAction_LinkGeneration_OverrideActionOverridesOrderOnController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -708,7 +710,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkGeneration_OrderOnActionOverridesOrderOnController() public async Task AttributeRoutedAction_LinkGeneration_OrderOnActionOverridesOrderOnController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -723,7 +725,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkToSelf() public async Task AttributeRoutedAction_LinkToSelf()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -746,7 +748,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkWithAmbientController() public async Task AttributeRoutedAction_LinkWithAmbientController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -769,7 +771,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkToAttributeRoutedController() public async Task AttributeRoutedAction_LinkToAttributeRoutedController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -793,7 +795,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkToConventionalController() public async Task AttributeRoutedAction_LinkToConventionalController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -818,7 +820,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkWithName_WithNameInheritedFromControllerRoute(string method, string actionName) public async Task AttributeRoutedAction_LinkWithName_WithNameInheritedFromControllerRoute(string method, string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -842,7 +844,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkWithName_WithNameOverrridenFromController() public async Task AttributeRoutedAction_LinkWithName_WithNameOverrridenFromController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -865,7 +867,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_Link_WithNonEmptyActionRouteTemplateAndNoActionRouteName() public async Task AttributeRoutedAction_Link_WithNonEmptyActionRouteTemplateAndNoActionRouteName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = LinkFrom("http://localhost") var url = LinkFrom("http://localhost")
@ -891,7 +893,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkWithName_WithNonEmptyActionRouteTemplateAndActionRouteName() public async Task AttributeRoutedAction_LinkWithName_WithNonEmptyActionRouteTemplateAndActionRouteName()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -918,7 +920,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_ThowsIfConventionalRouteWithTheSameName(string url) public async Task AttributeRoutedAction_ThowsIfConventionalRouteWithTheSameName(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMessage = "The supplied route name 'DuplicateRoute' is ambiguous and matched more than one route."; var expectedMessage = "The supplied route name 'DuplicateRoute' is ambiguous and matched more than one route.";
@ -935,7 +937,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionalRoutedAction_LinkToArea() public async Task ConventionalRoutedAction_LinkToArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -959,7 +961,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionalRoutedAction_InArea_ImplicitLinkToArea() public async Task ConventionalRoutedAction_InArea_ImplicitLinkToArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -982,7 +984,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionalRoutedAction_InArea_ExplicitLeaveArea() public async Task ConventionalRoutedAction_InArea_ExplicitLeaveArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1005,7 +1007,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionalRoutedAction_InArea_ImplicitLeaveArea() public async Task ConventionalRoutedAction_InArea_ImplicitLeaveArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1028,7 +1030,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_LinkToArea() public async Task AttributeRoutedAction_LinkToArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1052,7 +1054,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_InArea_ImplicitLinkToArea() public async Task AttributeRoutedAction_InArea_ImplicitLinkToArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1075,7 +1077,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_InArea_ExplicitLeaveArea() public async Task AttributeRoutedAction_InArea_ExplicitLeaveArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1099,7 +1101,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_InArea_ImplicitLeaveArea() public async Task AttributeRoutedAction_InArea_ImplicitLeaveArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1123,7 +1125,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_InArea_LinkToConventionalRoutedActionInArea() public async Task AttributeRoutedAction_InArea_LinkToConventionalRoutedActionInArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1148,7 +1150,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionalRoutedAction_InArea_LinkToAttributeRoutedActionInArea() public async Task ConventionalRoutedAction_InArea_LinkToAttributeRoutedActionInArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1173,7 +1175,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ConventionalRoutedAction_InArea_LinkToAnotherArea() public async Task ConventionalRoutedAction_InArea_LinkToAnotherArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1198,7 +1200,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_InArea_LinkToAnotherArea() public async Task AttributeRoutedAction_InArea_LinkToAnotherArea()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1223,7 +1225,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ControllerWithCatchAll_CanReachSpecificCountry() public async Task ControllerWithCatchAll_CanReachSpecificCountry()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1253,7 +1255,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ControllerWithCatchAll_CannotReachWithoutCountry() public async Task ControllerWithCatchAll_CannotReachWithoutCountry()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1267,7 +1269,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ControllerWithCatchAll_GenerateLinkForSpecificCountry() public async Task ControllerWithCatchAll_GenerateLinkForSpecificCountry()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1287,7 +1289,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ControllerWithCatchAll_GenerateLinkForFallback() public async Task ControllerWithCatchAll_GenerateLinkForFallback()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1307,7 +1309,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ControllerWithCatchAll_GenerateLink_FailsWithoutCountry() public async Task ControllerWithCatchAll_GenerateLink_FailsWithoutCountry()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -1332,7 +1334,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRouting_MixedAcceptVerbsAndRoute_Reachable(string path, string verb, string actionName) public async Task AttributeRouting_MixedAcceptVerbsAndRoute_Reachable(string path, string verb, string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(verb), "http://localhost" + path); var request = new HttpRequestMessage(new HttpMethod(verb), "http://localhost" + path);
@ -1359,7 +1361,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRouting_MixedAcceptVerbsAndRoute_Unreachable(string path, string verb) public async Task AttributeRouting_MixedAcceptVerbsAndRoute_Unreachable(string path, string verb)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(verb), "http://localhost" + path); var request = new HttpRequestMessage(new HttpMethod(verb), "http://localhost" + path);

View File

@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -17,6 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(XmlFormattersWebSite); private const string SiteName = nameof(XmlFormattersWebSite);
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new XmlFormattersWebSite.Startup().ConfigureServices;
[Theory] [Theory]
#if !DNXCORE50 #if !DNXCORE50
@ -26,7 +28,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ModelStateErrors_AreSerialized(string acceptHeader) public async Task ModelStateErrors_AreSerialized(string acceptHeader)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptHeader)); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptHeader));
var expectedXml = "<Error><key1>key1-error</key1><key2>The input was not valid.</key2></Error>"; var expectedXml = "<Error><key1>key1-error</key1><key2>The input was not valid.</key2></Error>";
@ -51,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task PostedSerializableError_IsBound(string acceptHeader) public async Task PostedSerializableError_IsBound(string acceptHeader)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptHeader)); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptHeader));
var expectedXml = "<Error><key1>key1-error</key1><key2>The input was not valid.</key2></Error>"; var expectedXml = "<Error><key1>key1-error</key1><key2>The input was not valid.</key2></Error>";
@ -75,7 +77,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task IsReturnedInExpectedFormat(string acceptHeader) public async Task IsReturnedInExpectedFormat(string acceptHeader)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Employee xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite.Models\">" + "<Employee xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite.Models\">" +

View File

@ -5,6 +5,7 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using FormatterWebSite; using FormatterWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -13,6 +14,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FormatterWebSite); private const string SiteName = nameof(FormatterWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("SimpleMemoryStream", null)] [InlineData("SimpleMemoryStream", null)]
@ -23,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task StreamOutputFormatter_ReturnsAppropriateContentAndContentType(string actionName, string contentType) public async Task StreamOutputFormatter_ReturnsAppropriateContentAndContentType(string actionName, string contentType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -7,6 +7,7 @@ using System.IO;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Xunit; using Xunit;
@ -38,12 +39,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
private readonly ILoggerFactory _loggerFactory = new TestLoggerFactory(); private readonly ILoggerFactory _loggerFactory = new TestLoggerFactory();
private readonly Action<IApplicationBuilder, ILoggerFactory> _app = new TagHelperSample.Web.Startup().Configure; private readonly Action<IApplicationBuilder, ILoggerFactory> _app = new TagHelperSample.Web.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new TagHelperSample.Web.Startup().ConfigureServices;
[Fact] [Fact]
public async Task Home_Pages_ReturnSuccess() public async Task Home_Pages_ReturnSuccess()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(app => _app(app, _loggerFactory), SiteName, SamplesFolder); var server = TestHelper.CreateServer(app => _app(app, _loggerFactory), SiteName, SamplesFolder, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
for (var index = 0; index < Paths.Count; index++) for (var index = 0; index < Paths.Count; index++)

View File

@ -10,6 +10,7 @@ using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using BasicWebSite; using BasicWebSite;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -18,6 +19,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(TagHelpersWebSite); private const string SiteName = nameof(TagHelpersWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
// Some tests require comparing the actual response body against an expected response baseline // Some tests require comparing the actual response body against an expected response baseline
// so they require a reference to the assembly on which the resources are located, in order to // so they require a reference to the assembly on which the resources are located, in order to
@ -32,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanRenderViewsWithTagHelpers(string action) public async Task CanRenderViewsWithTagHelpers(string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8"); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
@ -111,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TagHelpersAreInheritedFromGlobalImportPages(string action, string expected) public async Task TagHelpersAreInheritedFromGlobalImportPages(string action, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -125,7 +127,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewsWithModelMetadataAttributes_CanRenderForm() public async Task ViewsWithModelMetadataAttributes_CanRenderForm()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync( var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
"compiler/resources/TagHelpersWebSite.Employee.Create.html"); "compiler/resources/TagHelpersWebSite.Employee.Create.html");
@ -143,7 +145,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewsWithModelMetadataAttributes_CanRenderPostedValue() public async Task ViewsWithModelMetadataAttributes_CanRenderPostedValue()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync( var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
"compiler/resources/TagHelpersWebSite.Employee.Details.AfterCreate.html"); "compiler/resources/TagHelpersWebSite.Employee.Details.AfterCreate.html");
@ -171,7 +173,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ViewsWithModelMetadataAttributes_CanHandleInvalidData() public async Task ViewsWithModelMetadataAttributes_CanHandleInvalidData()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync( var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
"compiler/resources/TagHelpersWebSite.Employee.Create.Invalid.html"); "compiler/resources/TagHelpersWebSite.Employee.Create.Invalid.html");

View File

@ -7,6 +7,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,12 +16,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(TempDataWebSite); private const string SiteName = nameof(TempDataWebSite);
private readonly Action<IApplicationBuilder> _app = new TempDataWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new TempDataWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new TempDataWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ViewRendersTempData() public async Task ViewRendersTempData()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var nameValueCollection = new List<KeyValuePair<string, string>> var nameValueCollection = new List<KeyValuePair<string, string>>
{ {

View File

@ -5,10 +5,11 @@ using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
using Microsoft.Framework.Runtime; using Microsoft.Framework.Runtime;
using Microsoft.Framework.Runtime.Infrastructure;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
@ -42,7 +43,38 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
configureServices: configureServices); configureServices: configureServices);
} }
private static TestServer CreateServer( public static TestServer CreateServer(
Action<IApplicationBuilder> builder,
string applicationWebSiteName,
string applicationPath,
Func<IServiceCollection, IServiceProvider> configureServices)
{
return TestServer.Create(
CallContextServiceLocator.Locator.ServiceProvider,
builder,
services =>
{
AddTestServices(services, applicationWebSiteName, applicationPath, configureServices: null);
return (configureServices != null) ? configureServices(services) : services.BuildServiceProvider();
});
}
public static TestServer CreateServer(
Action<IApplicationBuilder> builder,
string applicationWebSiteName,
Func<IServiceCollection, IServiceProvider> configureServices)
{
return TestServer.Create(
CallContextServiceLocator.Locator.ServiceProvider,
builder,
services =>
{
AddTestServices(services, applicationWebSiteName, applicationPath: null, configureServices: null);
return configureServices(services);
});
}
public static TestServer CreateServer(
Action<IApplicationBuilder> builder, Action<IApplicationBuilder> builder,
string applicationWebSiteName, string applicationWebSiteName,
string applicationPath, string applicationPath,
@ -50,10 +82,10 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
return TestServer.Create( return TestServer.Create(
builder, builder,
services => AddServices(services, applicationWebSiteName, applicationPath, configureServices)); services => AddTestServices(services, applicationWebSiteName, applicationPath, configureServices));
} }
private static void AddServices( private static void AddTestServices(
IServiceCollection services, IServiceCollection services,
string applicationWebSiteName, string applicationWebSiteName,
string applicationPath, string applicationPath,
@ -81,10 +113,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
applicationBasePath, applicationBasePath,
applicationWebSiteName); applicationWebSiteName);
services.AddInstance<IApplicationEnvironment>(environment); services.AddInstance<IApplicationEnvironment>(environment);
services.AddInstance<IHostingEnvironment>(new HostingEnvironment(environment));
// Injecting a custom assembly provider. Overrides AddMvc() because that uses TryAdd(). // Injecting a custom assembly provider. Overrides AddMvc() because that uses TryAdd().
var assemblyProvider = CreateAssemblyProvider(applicationWebSiteName); var assemblyProvider = CreateAssemblyProvider(applicationWebSiteName);
services.AddInstance<IAssemblyProvider>(assemblyProvider); services.AddInstance(assemblyProvider);
if (configureServices != null) if (configureServices != null)
{ {

View File

@ -8,6 +8,7 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -17,12 +18,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ValidationWebSite); private const string SiteName = nameof(ValidationWebSite);
private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new ValidationWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task TryValidateModel_ClearParameterValidationError_ReturnsErrorsForInvalidProperties() public async Task TryValidateModel_ClearParameterValidationError_ReturnsErrorsForInvalidProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "{ \"Price\": 2, \"Contact\": \"acvrdzersaererererfdsfdsfdsfsdf\", "+ var input = "{ \"Price\": 2, \"Contact\": \"acvrdzersaererererfdsfdsfdsfsdf\", "+
"\"ProductDetails\": {\"Detail1\": \"d1\", \"Detail2\": \"d2\", \"Detail3\": \"d3\"}}"; "\"ProductDetails\": {\"Detail1\": \"d1\", \"Detail2\": \"d2\", \"Detail3\": \"d3\"}}";
@ -54,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryValidateModel_InvalidTypeOnDerivedModel_ReturnsErrors() public async Task TryValidateModel_InvalidTypeOnDerivedModel_ReturnsErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =
"http://localhost/ModelMetadataTypeValidation/TryValidateModelSoftwareViewModelWithPrefix"; "http://localhost/ModelMetadataTypeValidation/TryValidateModelSoftwareViewModelWithPrefix";
@ -73,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryValidateModel_ValidDerivedModel_ReturnsEmptyResponseBody() public async Task TryValidateModel_ValidDerivedModel_ReturnsEmptyResponseBody()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = var url =
"http://localhost/ModelMetadataTypeValidation/TryValidateModelValidModelNoPrefix"; "http://localhost/ModelMetadataTypeValidation/TryValidateModelValidModelNoPrefix";
@ -91,7 +93,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task TryValidateModel_CollectionsModel_ReturnsErrorsForInvalidProperties() public async Task TryValidateModel_CollectionsModel_ReturnsErrorsForInvalidProperties()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "[ { \"Price\": 2, \"Contact\": \"acvrdzersaererererfdsfdsfdsfsdf\", " + var input = "[ { \"Price\": 2, \"Contact\": \"acvrdzersaererererfdsfdsfdsfsdf\", " +
"\"ProductDetails\": {\"Detail1\": \"d1\", \"Detail2\": \"d2\", \"Detail3\": \"d3\"} }," + "\"ProductDetails\": {\"Detail1\": \"d1\", \"Detail2\": \"d2\", \"Detail3\": \"d3\"} }," +

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ValueProvidersWebSite; using ValueProvidersWebSite;
using Xunit; using Xunit;
@ -13,12 +14,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ValueProvidersWebSite); private const string SiteName = nameof(ValueProvidersWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
[Fact] [Fact]
public async Task ValueProviderFactories_AreVisitedInSequentialOrder_ForValueProviders() public async Task ValueProviderFactories_AreVisitedInSequentialOrder_ForValueProviders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -32,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ValueProviderFactories_ReturnsValuesFromQueryValueProvider() public async Task ValueProviderFactories_ReturnsValuesFromQueryValueProvider()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -46,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ValueProviderFactories_ReturnsValuesFromRouteValueProvider() public async Task ValueProviderFactories_ReturnsValuesFromRouteValueProvider()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -66,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ValueProvider_DeserializesEnumsWithFlags(string url, string expected) public async Task ValueProvider_DeserializesEnumsWithFlags(string url, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -7,6 +7,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -16,6 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(VersioningWebSite); private const string SiteName = nameof(VersioningWebSite);
readonly Action<IApplicationBuilder> _app = new VersioningWebSite.Startup().Configure; readonly Action<IApplicationBuilder> _app = new VersioningWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new VersioningWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("1")] [InlineData("1")]
@ -23,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_WithVersionedRoutes_IsNotAmbiguous(string version) public async Task AttributeRoutedAction_WithVersionedRoutes_IsNotAmbiguous(string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -48,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task AttributeRoutedAction_WithAmbiguousVersionedRoutes_CanBeDisambiguatedUsingOrder(string version) public async Task AttributeRoutedAction_WithAmbiguousVersionedRoutes_CanBeDisambiguatedUsingOrder(string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var query = "?version=" + version; var query = "?version=" + version;
var message = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/Addresses/All" + query); var message = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/Addresses/All" + query);
@ -73,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1Operations_OnTheSameController_WithNoVersionSpecified() public async Task VersionedApi_CanReachV1Operations_OnTheSameController_WithNoVersionSpecified()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -96,7 +98,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1Operations_OnTheSameController_WithVersionSpecified() public async Task VersionedApi_CanReachV1Operations_OnTheSameController_WithVersionSpecified()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -117,7 +119,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheSameController() public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheSameController()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -138,7 +140,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheSameController_WithVersionSpecified() public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheSameController_WithVersionSpecified()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -167,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachOtherVersionOperations_OnTheSameController(string version) public async Task VersionedApi_CanReachOtherVersionOperations_OnTheSameController(string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -193,7 +195,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanNotReachOtherVersionOperations_OnTheSameController_WithNoVersionSpecified() public async Task VersionedApi_CanNotReachOtherVersionOperations_OnTheSameController_WithNoVersionSpecified()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -220,7 +222,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
string version) string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -248,7 +250,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanNotReachOtherVersionOperationsWithParameters_OnTheSameController_WithNoVersionSpecified(string method) public async Task VersionedApi_CanNotReachOtherVersionOperationsWithParameters_OnTheSameController_WithNoVersionSpecified(string method)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -269,7 +271,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanUseOrderToDisambiguate_OverlappingVersionRanges(string version) public async Task VersionedApi_CanUseOrderToDisambiguate_OverlappingVersionRanges(string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -293,7 +295,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_OverlappingVersionRanges_FallsBackToLowerOrderAction(string version) public async Task VersionedApi_OverlappingVersionRanges_FallsBackToLowerOrderAction(string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -317,7 +319,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1Operations_OnTheOriginalController_WithNoVersionSpecified(string method, string action) public async Task VersionedApi_CanReachV1Operations_OnTheOriginalController_WithNoVersionSpecified(string method, string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -340,7 +342,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1Operations_OnTheOriginalController_WithVersionSpecified(string method, string action) public async Task VersionedApi_CanReachV1Operations_OnTheOriginalController_WithVersionSpecified(string method, string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -364,7 +366,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheOriginalController(string method, string action) public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheOriginalController(string method, string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -387,7 +389,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheOriginalController_WithVersionSpecified(string method, string action) public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheOriginalController_WithVersionSpecified(string method, string action)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -408,7 +410,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanReachOtherVersionOperationsWithParameters_OnTheV2Controller() public async Task VersionedApi_CanReachOtherVersionOperationsWithParameters_OnTheV2Controller()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -432,7 +434,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnTheSameAction(string url) public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnTheSameAction(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -455,7 +457,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnDifferentActions(string url, string version) public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnDifferentActions(string url, string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -478,7 +480,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnDifferentActions_WithInlineConstraint(string url, string version) public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnDifferentActions_WithInlineConstraint(string url, string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -504,7 +506,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanProvideVersioningInformation_UsingPlainActionConstraint(string url, string query, string actionName) public async Task VersionedApi_CanProvideVersioningInformation_UsingPlainActionConstraint(string url, string query, string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -525,7 +527,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_ConstraintOrder_IsRespected() public async Task VersionedApi_ConstraintOrder_IsRespected()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -546,7 +548,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_CanUseConstraintOrder_ToChangeSelectedAction() public async Task VersionedApi_CanUseConstraintOrder_ToChangeSelectedAction()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -569,7 +571,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task VersionedApi_MultipleVersionsUsingAttributeRouting_OnTheSameMethod(string version) public async Task VersionedApi_MultipleVersionsUsingAttributeRouting_OnTheSameMethod(string version)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var path = "/" + version + "/Vouchers?version=" + version; var path = "/" + version + "/Vouchers?version=" + version;

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using ViewComponentWebSite; using ViewComponentWebSite;
using Xunit; using Xunit;
@ -14,6 +15,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(ViewComponentWebSite); private const string SiteName = nameof(ViewComponentWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
public static IEnumerable<object[]> ViewViewComponents_AreRenderedCorrectlyData public static IEnumerable<object[]> ViewViewComponents_AreRenderedCorrectlyData
{ {
@ -41,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[MemberData(nameof(ViewViewComponents_AreRenderedCorrectlyData))] [MemberData(nameof(ViewViewComponents_AreRenderedCorrectlyData))]
public async Task ViewViewComponents_AreRenderedCorrectly(string actionName, string expected) public async Task ViewViewComponents_AreRenderedCorrectly(string actionName, string expected)
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -54,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task ViewComponents_SupportsValueType() public async Task ViewComponents_SupportsValueType()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -73,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[InlineData("http://localhost/Home/ViewComponentWithEnumerableModelUsingUnion", "Union")] [InlineData("http://localhost/Home/ViewComponentWithEnumerableModelUsingUnion", "Union")]
public async Task ViewComponents_SupportsEnumerableModel(string url, string linqQueryType) public async Task ViewComponents_SupportsEnumerableModel(string url, string linqQueryType)
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -92,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[InlineData("ViewComponentWebSite.Namespace2.SameName")] [InlineData("ViewComponentWebSite.Namespace2.SameName")]
public async Task ViewComponents_FullName(string name) public async Task ViewComponents_FullName(string name)
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -105,7 +107,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
[Fact] [Fact]
public async Task ViewComponents_ShortNameUsedForViewLookup() public async Task ViewComponents_ShortNameUsedForViewLookup()
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var name = "ViewComponentWebSite.Integer"; var name = "ViewComponentWebSite.Integer";

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using RazorWebSite; using RazorWebSite;
using Xunit; using Xunit;
@ -15,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(RazorWebSite); private const string SiteName = nameof(RazorWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
public static IEnumerable<object[]> RazorView_ExecutesPageAndLayoutData public static IEnumerable<object[]> RazorView_ExecutesPageAndLayoutData
{ {
@ -62,7 +64,7 @@ ViewWithNestedLayout-Content
[MemberData(nameof(RazorView_ExecutesPageAndLayoutData))] [MemberData(nameof(RazorView_ExecutesPageAndLayoutData))]
public async Task RazorView_ExecutesPageAndLayout(string actionName, string expected) public async Task RazorView_ExecutesPageAndLayout(string actionName, string expected)
{ {
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -83,7 +85,7 @@ ViewWithNestedLayout-Content
"", "",
"</partial2>", "</partial2>",
"test-value"); "test-value");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -98,7 +100,7 @@ ViewWithNestedLayout-Content
{ {
// Arrange // Arrange
var expected = "HelloWorld"; var expected = "HelloWorld";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -117,7 +119,7 @@ ViewWithNestedLayout-Content
partial-content partial-content
component-content"; component-content";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -153,7 +155,7 @@ component-content";
public async Task RazorViewEngine_UsesViewExpandersForViewsAndPartials(string value, string expected) public async Task RazorViewEngine_UsesViewExpandersForViewsAndPartials(string value, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -181,7 +183,7 @@ component-content";
public async Task ViewLocationExpanders_PassesInIsPartialToViewLocationExpanderContext(string action, string expected) public async Task ViewLocationExpanders_PassesInIsPartialToViewLocationExpanderContext(string action, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -246,7 +248,7 @@ ViewWithNestedLayout-Content
public async Task RazorViewEngine_RendersPartialViews(string actionName, string expected) public async Task RazorViewEngine_RendersPartialViews(string actionName, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -265,7 +267,7 @@ ViewWithNestedLayout-Content
"", "",
"~/Views/NestedViewStarts/NestedViewStarts/Layout.cshtml", "~/Views/NestedViewStarts/NestedViewStarts/Layout.cshtml",
"index-content"); "index-content");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -301,7 +303,7 @@ View With Layout
public async Task RazorViewEngine_UsesExpandersForLayouts(string value, string expected) public async Task RazorViewEngine_UsesExpandersForLayouts(string value, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -319,7 +321,7 @@ View With Layout
var expected = var expected =
@"<view-start>Hello Controller-Person</view-start> @"<view-start>Hello Controller-Person</view-start>
<page>Hello Controller-Person</page>"; <page>Hello Controller-Person</page>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var target = "http://localhost/NestedGlobalImports"; var target = "http://localhost/NestedGlobalImports";
@ -341,7 +343,7 @@ Page Content
<component-title>ViewComponent With Title</component-title> <component-title>ViewComponent With Title</component-title>
<component-body> <component-body>
Component With Layout</component-body>"; Component With Layout</component-body>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -356,7 +358,7 @@ Component With Layout</component-body>";
{ {
// Arrange // Arrange
var expected = @"<page-content>ViewComponent With ViewStart</page-content>"; var expected = @"<page-content>ViewComponent With ViewStart</page-content>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -371,7 +373,7 @@ Component With Layout</component-body>";
{ {
// Arrange // Arrange
var expected = "Partial that does not specify Layout"; var expected = "Partial that does not specify Layout";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -390,7 +392,7 @@ Component With Layout</component-body>";
Partial that specifies Layout Partial that specifies Layout
</layout-for-viewstart-with-layout>Partial that does not specify Layout </layout-for-viewstart-with-layout>Partial that does not specify Layout
</layout-for-viewstart-with-layout>"; </layout-for-viewstart-with-layout>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -410,7 +412,7 @@ Partial that specifies Layout
</layout-for-viewstart-with-layout> </layout-for-viewstart-with-layout>
Partial that does not specify Layout Partial that does not specify Layout
</layout-for-viewstart-with-layout>"; </layout-for-viewstart-with-layout>";
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -426,7 +428,7 @@ Partial that does not specify Layout
// Arrange // Arrange
var expected = await GetType().GetTypeInfo().Assembly var expected = await GetType().GetTypeInfo().Assembly
.ReadResourceAsStringAsync("compiler/resources/ViewEngineController.ViewWithPaths.txt"); .ReadResourceAsStringAsync("compiler/resources/ViewEngineController.ViewWithPaths.txt");
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -5,6 +5,7 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -13,12 +14,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(WebApiCompatShimWebSite); private const string SiteName = nameof(WebApiCompatShimWebSite);
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new WebApiCompatShimWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ApiController_BadRequest() public async Task ApiController_BadRequest()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -32,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_BadRequestMessage() public async Task ApiController_BadRequestMessage()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -48,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_BadRequestModelState() public async Task ApiController_BadRequestModelState()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = "{\"Message\":\"The request is invalid.\",\"ModelState\":{\"product.Name\":[\"Name is required.\"]}}"; var expected = "{\"Message\":\"The request is invalid.\",\"ModelState\":{\"product.Name\":[\"Name is required.\"]}}";
@ -66,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Conflict() public async Task ApiController_Conflict()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -80,7 +82,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Content() public async Task ApiController_Content()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -96,7 +98,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreatedRelative() public async Task ApiController_CreatedRelative()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -113,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreatedAbsolute() public async Task ApiController_CreatedAbsolute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -130,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreatedQualified() public async Task ApiController_CreatedQualified()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -147,7 +149,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreatedUri() public async Task ApiController_CreatedUri()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -164,7 +166,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreatedAtRoute() public async Task ApiController_CreatedAtRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -181,7 +183,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_InternalServerError() public async Task ApiController_InternalServerError()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -195,7 +197,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_InternalServerErrorException() public async Task ApiController_InternalServerErrorException()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -211,7 +213,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Json() public async Task ApiController_Json()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -227,7 +229,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_JsonSettings() public async Task ApiController_JsonSettings()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = var expected =
@ -248,7 +250,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_JsonSettingsEncoding() public async Task ApiController_JsonSettingsEncoding()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = var expected =
@ -270,7 +272,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_NotFound() public async Task ApiController_NotFound()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -284,7 +286,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Ok() public async Task ApiController_Ok()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -298,7 +300,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_OkContent() public async Task ApiController_OkContent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -314,7 +316,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_RedirectString() public async Task ApiController_RedirectString()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -329,7 +331,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_RedirectUri() public async Task ApiController_RedirectUri()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -344,7 +346,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_ResponseMessage() public async Task ApiController_ResponseMessage()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -359,7 +361,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_StatusCode() public async Task ApiController_StatusCode()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -15,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(WebApiCompatShimWebSite); private const string SiteName = nameof(WebApiCompatShimWebSite);
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new WebApiCompatShimWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("GET", "GetItems")] [InlineData("GET", "GetItems")]
@ -27,7 +29,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction(string httpMethod, string actionName) public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction(string httpMethod, string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -56,7 +58,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction(string httpMethod, string actionName) public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction(string httpMethod, string actionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -78,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_MismatchedVerb() public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_MismatchedVerb()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -96,7 +98,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction_DefaultVerbIsPost_Success() public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction_DefaultVerbIsPost_Success()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -118,7 +120,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_DefaultVerbIsPost_Success() public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_DefaultVerbIsPost_Success()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -140,7 +142,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction_DefaultVerbIsPost_VerbMismatch() public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction_DefaultVerbIsPost_VerbMismatch()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -158,7 +160,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_DefaultVerbIsPost_VerbMismatch() public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_DefaultVerbIsPost_VerbMismatch()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -176,7 +178,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_UnnamedAction_Success() public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_UnnamedAction_Success()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -198,7 +200,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_NamedAction_Success() public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_NamedAction_Success()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -220,7 +222,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_UnnamedAction_VerbMismatch() public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_UnnamedAction_VerbMismatch()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -238,7 +240,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_NamedAction_VerbMismatch() public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_NamedAction_VerbMismatch()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -256,7 +258,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_HttpMethodOverride_UnnamedAction_Success() public async Task WebAPIConvention_HttpMethodOverride_UnnamedAction_Success()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -278,7 +280,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_HttpMethodOverride_NamedAction_Success() public async Task WebAPIConvention_HttpMethodOverride_NamedAction_Success()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -300,7 +302,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_HttpMethodOverride_UnnamedAction_VerbMismatch() public async Task WebAPIConvention_HttpMethodOverride_UnnamedAction_VerbMismatch()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -318,7 +320,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebAPIConvention_HttpMethodOverride_NamedAction_VerbMismatch() public async Task WebAPIConvention_HttpMethodOverride_NamedAction_VerbMismatch()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -367,7 +369,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_OverloadedAction_WithUnnamedAction(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_OverloadedAction_WithUnnamedAction(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -394,7 +396,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_OverloadedAction_NonIdRouteParameter(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_OverloadedAction_NonIdRouteParameter(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -418,7 +420,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_OverloadedAction_Parameter_Casing(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_OverloadedAction_Parameter_Casing(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -445,7 +447,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_RouteWithActionName(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_RouteWithActionName(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -472,7 +474,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_RouteWithActionName_Casing(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_RouteWithActionName_Casing(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -497,7 +499,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_RouteWithoutActionName(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_RouteWithoutActionName(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -525,7 +527,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_ModelBindingParameterAttribute_AreAppliedWhenSelectingActions(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_ModelBindingParameterAttribute_AreAppliedWhenSelectingActions(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -549,7 +551,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_ActionsThatHaveSubsetOfRouteParameters_AreConsideredForSelection(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_ActionsThatHaveSubsetOfRouteParameters_AreConsideredForSelection(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
@ -571,7 +573,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_RequestToAmbiguousAction_OnDefaultRoute() public async Task LegacyActionSelection_RequestToAmbiguousAction_OnDefaultRoute()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "http://localhost/api/Admin/Test?name=mario"); var request = new HttpRequestMessage(new HttpMethod("POST"), "http://localhost/api/Admin/Test?name=mario");
@ -592,7 +594,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task LegacyActionSelection_SelectAction_ReturnsActionDescriptor_ForEnumParameterOverloads(string httpMethod, string requestUrl, string expectedActionName) public async Task LegacyActionSelection_SelectAction_ReturnsActionDescriptor_ForEnumParameterOverloads(string httpMethod, string requestUrl, string expectedActionName)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);

View File

@ -11,6 +11,7 @@ using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Http; using System.Web.Http;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -20,12 +21,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(WebApiCompatShimWebSite); private const string SiteName = nameof(WebApiCompatShimWebSite);
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new WebApiCompatShimWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task ApiController_Activates_HttpContextAndUser() public async Task ApiController_Activates_HttpContextAndUser()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -43,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Activates_UrlHelper() public async Task ApiController_Activates_UrlHelper()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -63,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task Options_SetsDefaultFormatters() public async Task Options_SetsDefaultFormatters()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = new string[] var expected = new string[]
@ -90,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionThrowsHttpResponseException_WithStatusCode() public async Task ActionThrowsHttpResponseException_WithStatusCode()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -107,7 +109,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionThrowsHttpResponseException_WithResponse() public async Task ActionThrowsHttpResponseException_WithResponse()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -125,7 +127,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionThrowsHttpResponseException_EnsureGlobalHttpresponseExceptionActionFilter_IsInvoked() public async Task ActionThrowsHttpResponseException_EnsureGlobalHttpresponseExceptionActionFilter_IsInvoked()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -143,7 +145,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ActionThrowsHttpResponseException_EnsureGlobalFilterConvention_IsApplied() public async Task ActionThrowsHttpResponseException_EnsureGlobalFilterConvention_IsApplied()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -162,7 +164,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CanValidateCustomObjectWithPrefix_Fails() public async Task ApiController_CanValidateCustomObjectWithPrefix_Fails()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -179,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CanValidateCustomObject_IsSuccessFul() public async Task ApiController_CanValidateCustomObject_IsSuccessFul()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -193,7 +195,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CanValidateCustomObject_Fails() public async Task ApiController_CanValidateCustomObject_Fails()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -209,7 +211,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_RequestProperty() public async Task ApiController_RequestProperty()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = var expected =
@ -231,7 +233,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_RequestParameter() public async Task ApiController_RequestParameter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = var expected =
@ -253,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_ResponseReturned() public async Task ApiController_ResponseReturned()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = var expected =
@ -279,7 +281,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_ExplicitChunkedEncoding_IsIgnored() public async Task ApiController_ExplicitChunkedEncoding_IsIgnored()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expected = var expected =
@ -324,7 +326,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreateResponse_Conneg(string accept, string mediaType) public async Task ApiController_CreateResponse_Conneg(string accept, string mediaType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -349,7 +351,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreateResponse_HardcodedMediaType(string mediaType) public async Task ApiController_CreateResponse_HardcodedMediaType(string mediaType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -374,7 +376,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreateResponse_Conneg_Error(string accept, string mediaType) public async Task ApiController_CreateResponse_Conneg_Error(string accept, string mediaType)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -397,7 +399,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_CreateResponse_HardcodedFormatter() public async Task ApiController_CreateResponse_HardcodedFormatter()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
@ -423,7 +425,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebApiRouting_AccessMvcController(string url, HttpStatusCode expected) public async Task WebApiRouting_AccessMvcController(string url, HttpStatusCode expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
@ -441,7 +443,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task WebApiRouting_AccessWebApiController(string url, HttpStatusCode expected) public async Task WebApiRouting_AccessWebApiController(string url, HttpStatusCode expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
@ -457,7 +459,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Returns_ByteArrayContent() public async Task ApiController_Returns_ByteArrayContent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedBody = "Hello from ByteArrayContent!!"; var expectedBody = "Hello from ByteArrayContent!!";
@ -477,7 +479,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Returns_StreamContent() public async Task ApiController_Returns_StreamContent()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedBody = "This content is from a file"; var expectedBody = "This content is from a file";
@ -501,7 +503,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Returns_PushStreamContent(string action, string expectedBody) public async Task ApiController_Returns_PushStreamContent(string action, string expectedBody)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
// Act // Act
@ -520,7 +522,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_Returns_PushStreamContentWithCustomHeaders() public async Task ApiController_Returns_PushStreamContentWithCustomHeaders()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var expectedBody = "Hello from PushStreamContent with custom headers!!"; var expectedBody = "Hello from PushStreamContent with custom headers!!";
var multipleValues = new[] { "value1", "value2" }; var multipleValues = new[] { "value1", "value2" };

View File

@ -8,6 +8,7 @@ using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -17,6 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(WebApiCompatShimWebSite); private const string SiteName = nameof(WebApiCompatShimWebSite);
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new WebApiCompatShimWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("http://localhost/api/Blog/Employees/PostByIdDefault/5")] [InlineData("http://localhost/api/Blog/Employees/PostByIdDefault/5")]
@ -24,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_SimpleParameter_Default_ReadsFromUrl(string url) public async Task ApiController_SimpleParameter_Default_ReadsFromUrl(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, url); var request = new HttpRequestMessage(HttpMethod.Post, url);
@ -42,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_SimpleParameter_Default_DoesNotReadFormData() public async Task ApiController_SimpleParameter_Default_DoesNotReadFormData()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/api/Blog/Employees/PostByIdDefault"; var url = "http://localhost/api/Blog/Employees/PostByIdDefault";
@ -67,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_SimpleParameter_ModelBinder_ReadsFromUrl(string url) public async Task ApiController_SimpleParameter_ModelBinder_ReadsFromUrl(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, url); var request = new HttpRequestMessage(HttpMethod.Post, url);
@ -85,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_SimpleParameter_ModelBinder_ReadsFromFormData() public async Task ApiController_SimpleParameter_ModelBinder_ReadsFromFormData()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/api/Blog/Employees/PostByIdModelBinder"; var url = "http://localhost/api/Blog/Employees/PostByIdModelBinder";
@ -110,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_SimpleParameter_FromQuery_ReadsFromQueryNotRouteData(string url, string expected) public async Task ApiController_SimpleParameter_FromQuery_ReadsFromQueryNotRouteData(string url, string expected)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, url); var request = new HttpRequestMessage(HttpMethod.Post, url);
@ -128,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_SimpleParameter_FromQuery_DoesNotReadFormData() public async Task ApiController_SimpleParameter_FromQuery_DoesNotReadFormData()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/api/Blog/Employees/PostByIdFromQuery"; var url = "http://localhost/api/Blog/Employees/PostByIdFromQuery";
@ -151,7 +153,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_ComplexParameter_Default_ReadsFromBody() public async Task ApiController_ComplexParameter_Default_ReadsFromBody()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/api/Blog/Employees/PutEmployeeDefault"; var url = "http://localhost/api/Blog/Employees/PutEmployeeDefault";
@ -176,7 +178,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_ComplexParameter_ModelBinder_ReadsFormAndUrl() public async Task ApiController_ComplexParameter_ModelBinder_ReadsFormAndUrl()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/api/Blog/Employees/PutEmployeeModelBinder/5"; var url = "http://localhost/api/Blog/Employees/PutEmployeeModelBinder/5";
@ -200,7 +202,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ApiController_TwoParameters_DefaultSources() public async Task ApiController_TwoParameters_DefaultSources()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var url = "http://localhost/api/Blog/Employees/PutEmployeeBothDefault?name=Name_Override"; var url = "http://localhost/api/Blog/Employees/PutEmployeeBothDefault?name=Name_Override";

View File

@ -8,6 +8,7 @@ using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -16,6 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(XmlFormattersWebSite); private const string SiteName = nameof(XmlFormattersWebSite);
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new XmlFormattersWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("http://localhost/IEnumerable/ValueTypes")] [InlineData("http://localhost/IEnumerable/ValueTypes")]
@ -23,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_ValueTypes(string url) public async Task CanWrite_ValueTypes(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
@ -46,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_NonWrappedTypes(string url) public async Task CanWrite_NonWrappedTypes(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
@ -69,7 +71,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_NonWrappedTypes_Empty(string url) public async Task CanWrite_NonWrappedTypes_Empty(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
@ -91,7 +93,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_NonWrappedTypes_NullInstance(string url) public async Task CanWrite_NonWrappedTypes_NullInstance(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
@ -113,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_WrappedTypes(string url) public async Task CanWrite_WrappedTypes(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
@ -137,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_WrappedTypes_Empty(string url) public async Task CanWrite_WrappedTypes_Empty(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
@ -159,7 +161,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_WrappedTypes_NullInstance(string url) public async Task CanWrite_WrappedTypes_NullInstance(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
@ -179,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_IEnumerableOf_SerializableErrors() public async Task CanWrite_IEnumerableOf_SerializableErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/IEnumerable/SerializableErrors"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/IEnumerable/SerializableErrors");
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));

View File

@ -12,6 +12,7 @@ using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using XmlFormattersWebSite; using XmlFormattersWebSite;
using Xunit; using Xunit;
@ -21,6 +22,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(XmlFormattersWebSite); private const string SiteName = nameof(XmlFormattersWebSite);
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
private readonly string errorMessageFormat = string.Format( private readonly string errorMessageFormat = string.Format(
"{{1}}:{0} does not recognize '{1}', so instead use '{2}' with '{3}' set to '{4}' for value " + "{{1}}:{0} does not recognize '{1}', so instead use '{2}' with '{3}' set to '{4}' for value " +
"type property '{{0}}' on type '{{1}}'.", "type property '{{0}}' on type '{{1}}'.",
@ -34,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ThrowsOnInvalidInput_AndAddsToModelState() public async Task ThrowsOnInvalidInput_AndAddsToModelState()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "Not a valid xml document"; var input = "Not a valid xml document";
var content = new StringContent(input, Encoding.UTF8, "application/xml-dcs"); var content = new StringContent(input, Encoding.UTF8, "application/xml-dcs");
@ -58,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task RequiredDataIsProvided_AndModelIsBound_AndHasRequiredAttributeValidationErrors() public async Task RequiredDataIsProvided_AndModelIsBound_AndHasRequiredAttributeValidationErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml-dcs")); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml-dcs"));
var input = "<Store xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite\" " + var input = "<Store xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite\" " +
@ -102,7 +104,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task DataMissingForReferneceTypeProperties_AndModelIsBound_AndHasMixedValidationErrors() public async Task DataMissingForReferneceTypeProperties_AndModelIsBound_AndHasMixedValidationErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml-dcs")); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml-dcs"));
var input = "<Store xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite\"" + var input = "<Store xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite\"" +

View File

@ -7,6 +7,7 @@ using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,12 +16,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(FormatterWebSite); private const string SiteName = nameof(FormatterWebSite);
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new FormatterWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task XmlDataContractSerializerOutputFormatterIsCalled() public async Task XmlDataContractSerializerOutputFormatterIsCalled()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Home/GetDummyClass?sampleInput=10"); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Home/GetDummyClass?sampleInput=10");
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8"));
@ -40,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task XmlSerializerOutputFormatterIsCalled() public async Task XmlSerializerOutputFormatterIsCalled()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/XmlSerializer/GetDummyClass?sampleInput=10"); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/XmlSerializer/GetDummyClass?sampleInput=10");
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8"));
@ -59,7 +61,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task XmlSerializerFailsAndDataContractSerializerIsCalled() public async Task XmlSerializerFailsAndDataContractSerializerIsCalled()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post, var request = new HttpRequestMessage(HttpMethod.Post,
"http://localhost/DataContractSerializer/GetPerson?name=HelloWorld"); "http://localhost/DataContractSerializer/GetPerson?name=HelloWorld");
@ -80,7 +82,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task XmlSerializerOutputFormatter_WhenDerivedClassIsReturned() public async Task XmlSerializerOutputFormatter_WhenDerivedClassIsReturned()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, "http://localhost/XmlSerializer/GetDerivedDummyClass?sampleInput=10"); HttpMethod.Post, "http://localhost/XmlSerializer/GetDerivedDummyClass?sampleInput=10");
@ -101,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task XmlDataContractSerializerOutputFormatter_WhenDerivedClassIsReturned() public async Task XmlDataContractSerializerOutputFormatter_WhenDerivedClassIsReturned()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, "http://localhost/Home/GetDerivedDummyClass?sampleInput=10"); HttpMethod.Post, "http://localhost/Home/GetDerivedDummyClass?sampleInput=10");
@ -122,7 +124,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task XmlSerializerFormatter_DoesNotWriteDictionaryObjects() public async Task XmlSerializerFormatter_DoesNotWriteDictionaryObjects()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage( var request = new HttpRequestMessage(
HttpMethod.Post, "http://localhost/XmlSerializer/GetDictionary"); HttpMethod.Post, "http://localhost/XmlSerializer/GetDictionary");

View File

@ -8,6 +8,7 @@ using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Mvc.Xml;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -16,6 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(XmlFormattersWebSite); private const string SiteName = nameof(XmlFormattersWebSite);
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new XmlFormattersWebSite.Startup().ConfigureServices;
[Theory] [Theory]
[InlineData("http://localhost/IEnumerable/ValueTypes")] [InlineData("http://localhost/IEnumerable/ValueTypes")]
@ -23,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_ValueTypes(string url) public async Task CanWrite_ValueTypes(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
@ -46,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_NonWrappedTypes(string url) public async Task CanWrite_NonWrappedTypes(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
@ -69,7 +71,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_NonWrappedTypes_NullInstance(string url) public async Task CanWrite_NonWrappedTypes_NullInstance(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
@ -91,7 +93,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_NonWrappedTypes_Empty(string url) public async Task CanWrite_NonWrappedTypes_Empty(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
@ -113,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_WrappedTypes(string url) public async Task CanWrite_WrappedTypes(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
@ -137,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_WrappedTypes_Empty(string url) public async Task CanWrite_WrappedTypes_Empty(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
@ -160,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_WrappedTypes_NullInstance(string url) public async Task CanWrite_WrappedTypes_NullInstance(string url)
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, url); var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
@ -181,7 +183,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task CanWrite_IEnumerableOf_SerializableErrors() public async Task CanWrite_IEnumerableOf_SerializableErrors()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/IEnumerable/SerializableErrors"); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/IEnumerable/SerializableErrors");
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser")); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));

View File

@ -7,6 +7,7 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Mvc.FunctionalTests namespace Microsoft.AspNet.Mvc.FunctionalTests
@ -15,12 +16,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
private const string SiteName = nameof(XmlFormattersWebSite); private const string SiteName = nameof(XmlFormattersWebSite);
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure; private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new XmlFormattersWebSite.Startup().ConfigureServices;
[Fact] [Fact]
public async Task CheckIfXmlSerializerInputFormatterIsCalled() public async Task CheckIfXmlSerializerInputFormatterIsCalled()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var sampleInputInt = 10; var sampleInputInt = 10;
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
@ -40,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
public async Task ThrowsOnInvalidInput_AndAddsToModelState() public async Task ThrowsOnInvalidInput_AndAddsToModelState()
{ {
// Arrange // Arrange
var server = TestHelper.CreateServer(_app, SiteName); var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient(); var client = server.CreateClient();
var input = "Not a valid xml document"; var input = "Not a valid xml document";
var content = new StringContent(input, Encoding.UTF8, "application/xml-xmlser"); var content = new StringContent(input, Encoding.UTF8, "application/xml-xmlser");

View File

@ -9,19 +9,20 @@ namespace ActionConstraintsWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.ConfigureMvc(options =>
{
options.AddXmlDataContractSerializerFormatter();
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
services.Configure<MvcOptions>(options =>
{
options.AddXmlDataContractSerializerFormatter();
});
});
app.UseErrorReporter(); app.UseErrorReporter();
app.UseMvc(routes => app.UseMvc(routes =>

View File

@ -9,21 +9,22 @@ namespace ActionResultsWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddInstance(new GuidLookupService());
services.ConfigureMvc(options =>
{
options.AddXmlDataContractSerializerFormatter();
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
services.AddInstance(new GuidLookupService());
services.Configure<MvcOptions>(options =>
{
options.AddXmlDataContractSerializerFormatter();
});
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute( routes.MapRoute(

View File

@ -8,19 +8,19 @@ namespace ActivatorWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
// Add MVC services to the services container
services.AddMvc();
services.AddInstance(new MyService());
services.AddScoped<ViewService, ViewService>();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
// Set up application services
app.UseServices(services =>
{
// Add MVC services to the services container
services.AddMvc();
services.AddInstance(new MyService());
services.AddScoped<ViewService, ViewService>();
});
// Used to report exceptions that MVC doesn't handle // Used to report exceptions that MVC doesn't handle
app.UseErrorReporter(); app.UseErrorReporter();

View File

@ -8,13 +8,15 @@ namespace AntiForgeryWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseErrorReporter(); app.UseErrorReporter();

View File

@ -10,29 +10,31 @@ namespace ApiExplorerWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton<ApiExplorerDataFilter>();
services.ConfigureMvc(options =>
{
options.Filters.AddService(typeof(ApiExplorerDataFilter));
options.Conventions.Add(new ApiExplorerVisibilityEnabledConvention());
options.Conventions.Add(new ApiExplorerVisibilityDisabledConvention(
typeof(ApiExplorerVisbilityDisabledByConventionController)));
options.OutputFormatters.Clear();
options.OutputFormatters.Add(new JsonOutputFormatter());
options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter());
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
services.AddSingleton<ApiExplorerDataFilter>();
services.Configure<MvcOptions>(options =>
{
options.Filters.AddService(typeof(ApiExplorerDataFilter));
options.Conventions.Add(new ApiExplorerVisibilityEnabledConvention());
options.Conventions.Add(new ApiExplorerVisibilityDisabledConvention(
typeof(ApiExplorerVisbilityDisabledByConventionController)));
options.OutputFormatters.Clear();
options.OutputFormatters.Add(new JsonOutputFormatter());
options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter());
});
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute("default", "{controller}/{action}"); routes.MapRoute("default", "{controller}/{action}");

View File

@ -9,22 +9,23 @@ namespace ApplicationModelWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.ConfigureMvc(options =>
{
options.Conventions.Add(new ApplicationDescription("Common Application Description"));
options.Conventions.Add(new ControllerLicenseConvention());
options.Conventions.Add(new FromHeaderConvention());
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
services.Configure<MvcOptions>(options =>
{
options.Conventions.Add(new ApplicationDescription("Common Application Description"));
options.Conventions.Add(new ControllerLicenseConvention());
options.Conventions.Add(new FromHeaderConvention());
});
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute( routes.MapRoute(

View File

@ -11,24 +11,25 @@ namespace AutofacWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddTransient<HelloWorldBuilder>();
var builder = new ContainerBuilder();
AutofacRegistration.Populate(builder,
services);
var container = builder.Build();
return container.Resolve<IServiceProvider>();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
services.AddTransient<HelloWorldBuilder>();
var builder = new ContainerBuilder();
AutofacRegistration.Populate(builder,
services);
var container = builder.Build();
return container.Resolve<IServiceProvider>();
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
// This default route is for running the project directly. // This default route is for running the project directly.

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Core;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;
@ -10,24 +9,25 @@ namespace BasicWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
// Add MVC services to the services container
services.AddMvc();
services.AddSingleton<IActionDescriptorProvider, ActionDescriptorCreationCounter>();
services.ConfigureMvc(options =>
{
options.Conventions.Add(new ApplicationDescription("This is a basic website."));
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
// Set up application services
app.UseServices(services =>
{
// Add MVC services to the services container
services.AddMvc();
services.AddSingleton<IActionDescriptorProvider, ActionDescriptorCreationCounter>();
services.ConfigureMvc(options =>
{
options.Conventions.Add(new ApplicationDescription("This is a basic website."));
});
});
// Add MVC to the request pipeline // Add MVC to the request pipeline
app.UseMvc(routes => app.UseMvc(routes =>
{ {

View File

@ -9,19 +9,21 @@ namespace BestEffortLinkGenerationWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<RouteOptions>((options) =>
{
options.UseBestEffortLinkGeneration = true;
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
services.Configure<RouteOptions>((options) =>
{
options.UseBestEffortLinkGeneration = true;
});
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute( routes.MapRoute(

View File

@ -9,21 +9,21 @@ namespace CompositeViewEngineWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
// Add a view engine as the first one in the list.
services.AddMvc()
.ConfigureMvc(options =>
{
options.ViewEngines.Insert(0, typeof(TestViewEngine));
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
// Set up application services
app.UseServices(services =>
{
// Add a view engine as the first one in the list.
services.AddMvc()
.Configure<MvcOptions>(options =>
{
options.ViewEngines.Insert(0, typeof(TestViewEngine));
});
});
// Add MVC to the request pipeline // Add MVC to the request pipeline
app.UseMvc(routes => app.UseMvc(routes =>
{ {

View File

@ -9,22 +9,21 @@ namespace ContentNegotiationWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.ConfigureMvc(options =>
{
options.AddXmlDataContractSerializerFormatter();
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
// Set up application services
app.UseServices(services =>
{
// Add MVC services to the services container
services.AddMvc();
services.Configure<MvcOptions>(options =>
{
options.AddXmlDataContractSerializerFormatter();
});
});
app.UseErrorReporter(); app.UseErrorReporter();
// Add MVC to the request pipeline // Add MVC to the request pipeline

View File

@ -8,15 +8,16 @@ namespace ControllerDiscoveryConventionsWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute("default", "{controller}/{action}/{id?}"); routes.MapRoute("default", "{controller}/{action}/{id?}");

View File

@ -16,35 +16,38 @@ namespace ControllersFromServicesWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.WithControllersAsServices(
new[]
{
typeof(TimeScheduleController).GetTypeInfo().Assembly
});
services.AddTransient<QueryValueService>();
#if DNX451
// Create the autofac container
var builder = new ContainerBuilder();
// Create the container and use the default application services as a fallback
AutofacRegistration.Populate(
builder,
services);
return builder.Build()
.Resolve<IServiceProvider>();
#else
return services.BuildServiceProvider();
#endif
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc()
.WithControllersAsServices(
new[]
{
typeof(TimeScheduleController).GetTypeInfo().Assembly
});
services.AddTransient<QueryValueService>();
#if DNX451
// Create the autofac container
var builder = new ContainerBuilder();
// Create the container and use the default application services as a fallback
AutofacRegistration.Populate(
builder,
services);
return builder.Build()
.Resolve<IServiceProvider>();
#endif
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute("default", "{controller}/{action}/{id}"); routes.MapRoute("default", "{controller}/{action}/{id}");

View File

@ -2,23 +2,21 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Cors;
using Microsoft.AspNet.Mvc;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;
namespace CorsMiddlewareWebSite namespace CorsMiddlewareWebSite
{ {
public class Startup public class Startup
{ {
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseCors(policy => policy.WithOrigins("http://example.com")); app.UseCors(policy => policy.WithOrigins("http://example.com"));
app.UseMvc(); app.UseMvc();
} }

View File

@ -2,58 +2,57 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;
namespace CorsWebSite namespace CorsWebSite
{ {
public class Startup public class Startup
{ {
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.ConfigureCors(options =>
{
options.AddPolicy(
"AllowAnySimpleRequest",
builder =>
{
builder.AllowAnyOrigin()
.WithMethods("GET", "POST", "HEAD");
});
options.AddPolicy(
"AllowSpecificOrigin",
builder =>
{
builder.WithOrigins("http://example.com");
});
options.AddPolicy(
"WithCredentials",
builder =>
{
builder.AllowCredentials()
.WithOrigins("http://example.com");
});
options.AddPolicy(
"WithCredentialsAnyOrigin",
builder =>
{
builder.AllowCredentials()
.AllowAnyOrigin()
.AllowAnyHeader()
.WithMethods("PUT", "POST")
.WithExposedHeaders("exposed1", "exposed2");
});
});
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
services.ConfigureCors(options =>
{
options.AddPolicy(
"AllowAnySimpleRequest",
builder =>
{
builder.AllowAnyOrigin()
.WithMethods("GET", "POST", "HEAD");
});
options.AddPolicy(
"AllowSpecificOrigin",
builder =>
{
builder.WithOrigins("http://example.com");
});
options.AddPolicy(
"WithCredentials",
builder =>
{
builder.AllowCredentials()
.WithOrigins("http://example.com");
});
options.AddPolicy(
"WithCredentialsAnyOrigin",
builder =>
{
builder.AllowCredentials()
.AllowAnyOrigin()
.AllowAnyHeader()
.WithMethods("PUT", "POST")
.WithExposedHeaders("exposed1", "exposed2");
});
});
});
app.UseMvc(); app.UseMvc();
} }
} }

View File

@ -8,15 +8,16 @@ namespace CustomRouteWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.DefaultHandler = new LocalizedRoute(routes.DefaultHandler); routes.DefaultHandler = new LocalizedRoute(routes.DefaultHandler);

View File

@ -8,15 +8,16 @@ namespace ErrorPageMiddlewareWebSite
{ {
public class Startup public class Startup
{ {
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
var configuration = app.GetTestConfiguration(); var configuration = app.GetTestConfiguration();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseErrorPage(); app.UseErrorPage();
app.UseMvc(); app.UseMvc();
} }

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