Remove use of `ServiceDescriber` in MVC and cleanup related hacks
- see issues aspnet/DependencyInjection#193 and #1612 - use `TryAdd()` in `MvcServices` for the `IAssemblyProvider` Move `ApplicationBasePath` handling into `RazorPreCompileModule` - restores view precompilation in functional tests of sample sites - if we need this, others will as well - override `IApplicationEnvironment` but get folder from `ProjectContext` - also remove remaining `IServiceProvider` implementations in this code test fixes: - simplify `IApplicationEnvironment` override - move override logic into `TestHelper.CreateServer()` methods - remove `LoggerFactory` setup - does not seem to require special-casing - remove unused `ITestConfigurationProvider` / `TestConfigurationProvider` - remove `TestAssemblyProvider` classes - no longer required - remove `ReplaceCallContextServiceLocationService` test helper - change MVC sample to fully-qualify config.json path - avoids `ReplaceCallContextServiceLocationService` need in `MvcSampleTests` - no longer required for other tests nit: remove unused `_serviceProvider` and constructor overload in `RazorPreCompiler`
This commit is contained in:
parent
db728cd386
commit
cc7b319cb7
|
|
@ -1,19 +1,25 @@
|
|||
// 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.
|
||||
|
||||
#if DNX451
|
||||
using System;
|
||||
using System.IO;
|
||||
using Autofac;
|
||||
#endif
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
#if DNX451
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
#endif
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
#if DNX451
|
||||
using Microsoft.Framework.DependencyInjection.Autofac;
|
||||
using Microsoft.Framework.Runtime;
|
||||
#endif
|
||||
using MvcSample.Web.Filters;
|
||||
using MvcSample.Web.Services;
|
||||
|
||||
#if DNX451
|
||||
using Autofac;
|
||||
using Microsoft.Framework.DependencyInjection.Autofac;
|
||||
#endif
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
|
|
@ -22,15 +28,21 @@ namespace MvcSample.Web
|
|||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseStatusCodePages();
|
||||
|
||||
app.UseFileServer();
|
||||
|
||||
#if DNX451
|
||||
// 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.
|
||||
// Functional tests update that service but not in the static provider.
|
||||
var applicationEnvironment = app.ApplicationServices.GetRequiredService<IApplicationEnvironment>();
|
||||
var configurationPath = Path.Combine(applicationEnvironment.ApplicationBasePath, "config.json");
|
||||
|
||||
// Set up configuration sources.
|
||||
var configuration = new Configuration()
|
||||
.AddJsonFile("config.json")
|
||||
.AddEnvironmentVariables();
|
||||
string diSystem;
|
||||
.AddJsonFile(configurationPath)
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
string diSystem;
|
||||
if (configuration.TryGet("DependencyInjection", out diSystem) &&
|
||||
diSystem.Equals("AutoFac", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
|
@ -46,14 +58,10 @@ namespace MvcSample.Web
|
|||
services.AddSingleton<UserNameService>();
|
||||
services.AddTransient<ITestService, TestService>();
|
||||
|
||||
// Setup services with a test AssemblyProvider so that only the
|
||||
// sample's assemblies are loaded. This prevents loading controllers from other assemblies
|
||||
// when the sample is used in the Functional Tests.
|
||||
services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
|
||||
services.ConfigureMvcOptions(options =>
|
||||
{
|
||||
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
|
||||
options.AddXmlDataContractSerializerFormatter();
|
||||
options.AddXmlDataContractSerializerFormatter();
|
||||
options.Filters.Add(new FormatFilterAttribute());
|
||||
});
|
||||
services.ConfigureRazorViewEngineOptions(options =>
|
||||
|
|
@ -90,11 +98,6 @@ namespace MvcSample.Web
|
|||
services.AddSingleton<PassThroughAttribute>();
|
||||
services.AddSingleton<UserNameService>();
|
||||
services.AddTransient<ITestService, TestService>();
|
||||
|
||||
// Setup services with a test AssemblyProvider so that only the
|
||||
// sample's assemblies are loaded. This prevents loading controllers from other assemblies
|
||||
// when the sample is used in the Functional Tests.
|
||||
services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
|
||||
|
||||
services.ConfigureMvcOptions(options =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Limits MVC to use a single Assembly for controller discovery.
|
||||
/// This is used by the functional test to limit the Controller discovery to
|
||||
/// MvcSample.Web Assembly alone.
|
||||
/// The sample should work in the absense of this file.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is a generic type because it needs to instantiated by a service provider to replace
|
||||
/// a built-in MVC service.
|
||||
/// </remarks>
|
||||
public class TestAssemblyProvider<T> : IAssemblyProvider
|
||||
{
|
||||
public TestAssemblyProvider()
|
||||
{
|
||||
CandidateAssemblies = new Assembly[] { typeof(T).GetTypeInfo().Assembly };
|
||||
}
|
||||
|
||||
public IEnumerable<Assembly> CandidateAssemblies { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Microsoft.Framework.Logging.Console;
|
||||
using TagHelperSample.Web.Services;
|
||||
|
||||
namespace TagHelperSample.Web
|
||||
|
|
@ -19,9 +17,6 @@ namespace TagHelperSample.Web
|
|||
{
|
||||
services.AddMvc();
|
||||
|
||||
// Setup services with a test AssemblyProvider so that only the sample's assemblies are loaded. This
|
||||
// prevents loading controllers from other assemblies when the sample is used in functional tests.
|
||||
services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
|
||||
services.AddSingleton<MoviesService>();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace TagHelperSample.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Limits MVC to use a single Assembly for controller discovery. This is used by the functional test to limit the
|
||||
/// Controller discovery to TagHelperSample.Web Assembly alone. The sample should work in the absence of this file
|
||||
/// when not run from a functional test.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is a generic type because it needs to instantiated by a service provider to replace a built-in MVC
|
||||
/// service.
|
||||
/// </remarks>
|
||||
public class TestAssemblyProvider<T> : IAssemblyProvider
|
||||
{
|
||||
public TestAssemblyProvider()
|
||||
{
|
||||
CandidateAssemblies = new Assembly[] { typeof(T).GetTypeInfo().Assembly };
|
||||
}
|
||||
|
||||
public IEnumerable<Assembly> CandidateAssemblies { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -24,30 +24,29 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
{
|
||||
public class RazorPreCompiler
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IFileProvider _fileProvider;
|
||||
|
||||
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider,
|
||||
[NotNull] IBeforeCompileContext compileContext,
|
||||
[NotNull] IMemoryCache precompilationCache,
|
||||
[NotNull] CompilationSettings compilationSettings) :
|
||||
this(designTimeServiceProvider,
|
||||
compileContext,
|
||||
designTimeServiceProvider.GetRequiredService<IAssemblyLoadContextAccessor>(),
|
||||
designTimeServiceProvider.GetRequiredService<IOptions<RazorViewEngineOptions>>(),
|
||||
precompilationCache,
|
||||
compilationSettings)
|
||||
public RazorPreCompiler(
|
||||
[NotNull] IServiceProvider designTimeServiceProvider,
|
||||
[NotNull] IBeforeCompileContext compileContext,
|
||||
[NotNull] IMemoryCache precompilationCache,
|
||||
[NotNull] CompilationSettings compilationSettings)
|
||||
: this(
|
||||
compileContext,
|
||||
designTimeServiceProvider.GetRequiredService<IAssemblyLoadContextAccessor>(),
|
||||
designTimeServiceProvider.GetRequiredService<IOptions<RazorViewEngineOptions>>(),
|
||||
precompilationCache,
|
||||
compilationSettings)
|
||||
{
|
||||
}
|
||||
|
||||
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider,
|
||||
[NotNull] IBeforeCompileContext compileContext,
|
||||
[NotNull] IAssemblyLoadContextAccessor loadContextAccessor,
|
||||
[NotNull] IOptions<RazorViewEngineOptions> optionsAccessor,
|
||||
[NotNull] IMemoryCache precompilationCache,
|
||||
[NotNull] CompilationSettings compilationSettings)
|
||||
private RazorPreCompiler(
|
||||
[NotNull] IBeforeCompileContext compileContext,
|
||||
[NotNull] IAssemblyLoadContextAccessor loadContextAccessor,
|
||||
[NotNull] IOptions<RazorViewEngineOptions> optionsAccessor,
|
||||
[NotNull] IMemoryCache precompilationCache,
|
||||
[NotNull] CompilationSettings compilationSettings)
|
||||
{
|
||||
_serviceProvider = designTimeServiceProvider;
|
||||
CompileContext = compileContext;
|
||||
LoadContext = loadContextAccessor.GetLoadContext(GetType().GetTypeInfo().Assembly);
|
||||
_fileProvider = optionsAccessor.Options.FileProvider;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
IConfiguration configuration)
|
||||
{
|
||||
ConfigureDefaultServices(services, configuration);
|
||||
services.TryAdd(MvcServices.GetDefaultServices(configuration));
|
||||
services.TryAdd(MvcServices.GetDefaultServices());
|
||||
return services;
|
||||
}
|
||||
|
||||
|
|
@ -46,29 +46,12 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
/// discovery.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
|
||||
/// <param name="controllerTypes">A sequence of controller <see cref="Type"/>s to register in the <paramref name="services"/>
|
||||
/// and used for controller discovery.</param>
|
||||
/// <param name="controllerTypes">A sequence of controller <see cref="Type"/>s to register in the
|
||||
/// <paramref name="services"/> and used for controller discovery.</param>
|
||||
/// <returns>The <see cref="IServiceCollection"/>.</returns>
|
||||
public static IServiceCollection WithControllersAsServices(
|
||||
[NotNull] this IServiceCollection services,
|
||||
[NotNull] IEnumerable<Type> controllerTypes)
|
||||
{
|
||||
return WithControllersAsServices(services, controllerTypes, configuration: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register the specified <paramref name="controllerTypes"/> as services and as a source for controller
|
||||
/// discovery.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
|
||||
/// <param name="controllerTypes">A sequence of controller <see cref="Type"/>s to register
|
||||
/// in the <paramref name="services"/> and used for controller discovery.</param>
|
||||
/// <param name="configuration">The application's <see cref="IConfiguration"/>.</param>
|
||||
/// <returns>The <see cref="IServiceCollection"/>.</returns>
|
||||
public static IServiceCollection WithControllersAsServices(
|
||||
[NotNull] this IServiceCollection services,
|
||||
[NotNull] IEnumerable<Type> controllerTypes,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
var controllerTypeProvider = new FixedSetControllerTypeProvider();
|
||||
foreach (var type in controllerTypes)
|
||||
|
|
@ -77,9 +60,8 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
controllerTypeProvider.ControllerTypes.Add(type.GetTypeInfo());
|
||||
}
|
||||
|
||||
var describer = new ServiceDescriber(configuration);
|
||||
services.Replace(describer.Transient<IControllerActivator, ServiceBasedControllerActivator>());
|
||||
services.Replace(describer.Instance<IControllerTypeProvider>(controllerTypeProvider));
|
||||
services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
|
||||
services.Replace(ServiceDescriptor.Instance<IControllerTypeProvider>(controllerTypeProvider));
|
||||
|
||||
return services;
|
||||
}
|
||||
|
|
@ -94,24 +76,6 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
public static IServiceCollection WithControllersAsServices(
|
||||
[NotNull] this IServiceCollection services,
|
||||
[NotNull] IEnumerable<Assembly> controllerAssemblies)
|
||||
{
|
||||
return WithControllersAsServices(services,
|
||||
controllerAssemblies,
|
||||
configuration: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers controller types from the specified <paramref name="assemblies"/> as services and as a source
|
||||
/// for controller discovery.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
|
||||
/// <param name="controllerAssemblies">Assemblies to scan.</param>
|
||||
/// <param name="configuration">The application's <see cref="IConfiguration"/>.</param>
|
||||
/// <returns>The <see cref="IServiceCollection"/>.</returns>
|
||||
public static IServiceCollection WithControllersAsServices(
|
||||
[NotNull] this IServiceCollection services,
|
||||
[NotNull] IEnumerable<Assembly> controllerAssemblies,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
var assemblyProvider = new FixedSetAssemblyProvider();
|
||||
foreach (var assembly in controllerAssemblies)
|
||||
|
|
@ -123,9 +87,7 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
var controllerTypeProvider = new DefaultControllerTypeProvider(assemblyProvider, loggerFactory);
|
||||
var controllerTypes = controllerTypeProvider.ControllerTypes;
|
||||
|
||||
return WithControllersAsServices(services,
|
||||
controllerTypes.Select(type => type.AsType()),
|
||||
configuration);
|
||||
return WithControllersAsServices(services, controllerTypes.Select(type => type.AsType()));
|
||||
}
|
||||
|
||||
private static void ConfigureDefaultServices(IServiceCollection services, IConfiguration configuration)
|
||||
|
|
@ -135,10 +97,8 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
services.AddRouting();
|
||||
services.AddAuthorization(configuration);
|
||||
services.AddWebEncoders();
|
||||
services.Configure<RouteOptions>(routeOptions =>
|
||||
routeOptions.ConstraintMap
|
||||
.Add("exists",
|
||||
typeof(KnownRouteValueConstraint)));
|
||||
services.Configure<RouteOptions>(
|
||||
routeOptions => routeOptions.ConstraintMap.Add("exists", typeof(KnownRouteValueConstraint)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Mvc.ActionConstraints;
|
||||
using Microsoft.AspNet.Mvc.ApplicationModels;
|
||||
using Microsoft.AspNet.Mvc.Core;
|
||||
|
|
@ -18,7 +17,6 @@ using Microsoft.AspNet.Mvc.Rendering;
|
|||
using Microsoft.AspNet.Mvc.Routing;
|
||||
using Microsoft.AspNet.Mvc.ViewComponents;
|
||||
using Microsoft.Framework.Cache.Memory;
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
|
||||
|
|
@ -26,161 +24,155 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
public class MvcServices
|
||||
{
|
||||
public static IEnumerable<ServiceDescriptor> GetDefaultServices()
|
||||
public static IServiceCollection GetDefaultServices()
|
||||
{
|
||||
return GetDefaultServices(null);
|
||||
}
|
||||
|
||||
public static IEnumerable<ServiceDescriptor> GetDefaultServices(IConfiguration configuration)
|
||||
{
|
||||
var describe = new ServiceDescriber(configuration);
|
||||
var services = new ServiceCollection();
|
||||
|
||||
// Options and core services.
|
||||
yield return describe.Transient<IConfigureOptions<MvcOptions>, MvcOptionsSetup>();
|
||||
yield return describe.Transient<IConfigureOptions<RazorViewEngineOptions>, RazorViewEngineOptionsSetup>();
|
||||
yield return describe.Transient<IAssemblyProvider, DefaultAssemblyProvider>();
|
||||
services.AddTransient<IConfigureOptions<MvcOptions>, MvcOptionsSetup>();
|
||||
services.AddTransient<IConfigureOptions<RazorViewEngineOptions>, RazorViewEngineOptionsSetup>();
|
||||
|
||||
yield return describe.Transient<MvcMarkerService, MvcMarkerService>();
|
||||
yield return describe.Singleton(typeof(ITypeActivatorCache), typeof(DefaultTypeActivatorCache));
|
||||
yield return describe.Scoped(typeof(IScopedInstance<>), typeof(ScopedInstance<>));
|
||||
// TryAdd() so functional tests can override this particular service. Test setup runs before this method.
|
||||
services.TryAdd(ServiceDescriptor.Transient<IAssemblyProvider, DefaultAssemblyProvider>());
|
||||
|
||||
services.AddTransient<MvcMarkerService, MvcMarkerService>();
|
||||
services.AddSingleton<ITypeActivatorCache, DefaultTypeActivatorCache>();
|
||||
services.AddScoped(typeof(IScopedInstance<>), typeof(ScopedInstance<>));
|
||||
|
||||
// Core action discovery, filters and action execution.
|
||||
|
||||
// These are consumed only when creating action descriptors, then they can be de-allocated
|
||||
yield return describe.Transient<IControllerTypeProvider, DefaultControllerTypeProvider>();
|
||||
yield return describe.Transient<IControllerModelBuilder, DefaultControllerModelBuilder>();
|
||||
yield return describe.Transient<IActionModelBuilder, DefaultActionModelBuilder>();
|
||||
services.AddTransient<IControllerTypeProvider, DefaultControllerTypeProvider>();
|
||||
services.AddTransient<IControllerModelBuilder, DefaultControllerModelBuilder>();
|
||||
services.AddTransient<IActionModelBuilder, DefaultActionModelBuilder>();
|
||||
|
||||
// This has a cache, so it needs to be a singleton
|
||||
yield return describe.Singleton<IControllerFactory, DefaultControllerFactory>();
|
||||
services.AddSingleton<IControllerFactory, DefaultControllerFactory>();
|
||||
|
||||
yield return describe.Transient<IControllerActivator, DefaultControllerActivator>();
|
||||
services.AddTransient<IControllerActivator, DefaultControllerActivator>();
|
||||
|
||||
// This accesses per-reqest services
|
||||
yield return describe.Transient<IActionInvokerFactory, ActionInvokerFactory>();
|
||||
services.AddTransient<IActionInvokerFactory, ActionInvokerFactory>();
|
||||
|
||||
// This provider needs access to the per-request services, but might be used many times for a given
|
||||
// request.
|
||||
yield return describe.Transient<IActionConstraintProvider, DefaultActionConstraintProvider>();
|
||||
services.AddTransient<IActionConstraintProvider, DefaultActionConstraintProvider>();
|
||||
|
||||
yield return describe.Singleton<IActionSelectorDecisionTreeProvider, ActionSelectorDecisionTreeProvider>();
|
||||
yield return describe.Singleton<IActionSelector, DefaultActionSelector>();
|
||||
yield return describe.Transient<IControllerActionArgumentBinder, DefaultControllerActionArgumentBinder>();
|
||||
yield return describe.Transient<IObjectModelValidator, DefaultObjectValidator>();
|
||||
services.AddSingleton<IActionSelectorDecisionTreeProvider, ActionSelectorDecisionTreeProvider>();
|
||||
services.AddSingleton<IActionSelector, DefaultActionSelector>();
|
||||
services.AddTransient<IControllerActionArgumentBinder, DefaultControllerActionArgumentBinder>();
|
||||
services.AddTransient<IObjectModelValidator, DefaultObjectValidator>();
|
||||
|
||||
yield return describe.Transient<IActionDescriptorProvider, ControllerActionDescriptorProvider>();
|
||||
services.AddTransient<IActionDescriptorProvider, ControllerActionDescriptorProvider>();
|
||||
|
||||
yield return describe.Transient<IActionInvokerProvider,
|
||||
ControllerActionInvokerProvider>();
|
||||
services.AddTransient<IActionInvokerProvider, ControllerActionInvokerProvider>();
|
||||
|
||||
yield return describe.Singleton<IActionDescriptorsCollectionProvider,
|
||||
DefaultActionDescriptorsCollectionProvider>();
|
||||
services.AddSingleton<IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>();
|
||||
|
||||
// The IGlobalFilterProvider is used to build the action descriptors (likely once) and so should
|
||||
// remain transient to avoid keeping it in memory.
|
||||
yield return describe.Transient<IGlobalFilterProvider, DefaultGlobalFilterProvider>();
|
||||
yield return describe.Transient<IFilterProvider, DefaultFilterProvider>();
|
||||
services.AddTransient<IGlobalFilterProvider, DefaultGlobalFilterProvider>();
|
||||
services.AddTransient<IFilterProvider, DefaultFilterProvider>();
|
||||
|
||||
yield return describe.Transient<FormatFilter, FormatFilter>();
|
||||
services.AddTransient<FormatFilter, FormatFilter>();
|
||||
|
||||
// Dataflow - ModelBinding, Validation and Formatting
|
||||
//
|
||||
// The DefaultModelMetadataProvider does significant caching and should be a singleton.
|
||||
yield return describe.Singleton<ModelBinding.IModelMetadataProvider, DefaultModelMetadataProvider>();
|
||||
yield return describe.Transient<ModelBinding.Metadata.ICompositeMetadataDetailsProvider>(services =>
|
||||
services.AddSingleton<ModelBinding.IModelMetadataProvider, DefaultModelMetadataProvider>();
|
||||
services.AddTransient<ModelBinding.Metadata.ICompositeMetadataDetailsProvider>(serviceProvider =>
|
||||
{
|
||||
var options = services.GetRequiredService<IOptions<MvcOptions>>().Options;
|
||||
var options = serviceProvider.GetRequiredService<IOptions<MvcOptions>>().Options;
|
||||
return new DefaultCompositeMetadataDetailsProvider(options.ModelMetadataDetailsProviders);
|
||||
});
|
||||
|
||||
yield return describe.Transient<IInputFormatterSelector, DefaultInputFormatterSelector>();
|
||||
yield return describe.Scoped<IInputFormattersProvider, DefaultInputFormattersProvider>();
|
||||
services.AddTransient<IInputFormatterSelector, DefaultInputFormatterSelector>();
|
||||
services.AddScoped<IInputFormattersProvider, DefaultInputFormattersProvider>();
|
||||
|
||||
yield return describe.Transient<IModelBinderProvider, DefaultModelBindersProvider>();
|
||||
yield return describe.Transient<IValueProviderFactoryProvider, DefaultValueProviderFactoryProvider>();
|
||||
yield return describe.Transient<IOutputFormattersProvider, DefaultOutputFormattersProvider>();
|
||||
yield return describe.Instance(new JsonOutputFormatter());
|
||||
services.AddTransient<IModelBinderProvider, DefaultModelBindersProvider>();
|
||||
services.AddTransient<IValueProviderFactoryProvider, DefaultValueProviderFactoryProvider>();
|
||||
services.AddTransient<IOutputFormattersProvider, DefaultOutputFormattersProvider>();
|
||||
services.AddInstance(new JsonOutputFormatter());
|
||||
|
||||
yield return describe.Transient<IModelValidatorProviderProvider, DefaultModelValidatorProviderProvider>();
|
||||
yield return describe.Transient<IValidationExcludeFiltersProvider,
|
||||
DefaultValidationExcludeFiltersProvider>();
|
||||
services.AddTransient<IModelValidatorProviderProvider, DefaultModelValidatorProviderProvider>();
|
||||
services.AddTransient<IValidationExcludeFiltersProvider, DefaultValidationExcludeFiltersProvider>();
|
||||
|
||||
// Razor, Views and runtime compilation
|
||||
|
||||
// The provider is inexpensive to initialize and provides ViewEngines that may require request
|
||||
// specific services.
|
||||
yield return describe.Scoped<ICompositeViewEngine, CompositeViewEngine>();
|
||||
yield return describe.Transient<IViewEngineProvider, DefaultViewEngineProvider>();
|
||||
services.AddScoped<ICompositeViewEngine, CompositeViewEngine>();
|
||||
services.AddTransient<IViewEngineProvider, DefaultViewEngineProvider>();
|
||||
// Transient since the IViewLocationExpanders returned by the instance is cached by view engines.
|
||||
yield return describe.Transient<IViewLocationExpanderProvider, DefaultViewLocationExpanderProvider>();
|
||||
services.AddTransient<IViewLocationExpanderProvider, DefaultViewLocationExpanderProvider>();
|
||||
// Caches view locations that are valid for the lifetime of the application.
|
||||
yield return describe.Singleton<IViewLocationCache, DefaultViewLocationCache>();
|
||||
yield return describe.Singleton<ICodeTreeCache>(serviceProvider =>
|
||||
services.AddSingleton<IViewLocationCache, DefaultViewLocationCache>();
|
||||
services.AddSingleton<ICodeTreeCache>(serviceProvider =>
|
||||
{
|
||||
var cachedFileProvider = serviceProvider.GetRequiredService<IOptions<RazorViewEngineOptions>>();
|
||||
return new DefaultCodeTreeCache(cachedFileProvider.Options.FileProvider);
|
||||
});
|
||||
|
||||
// The host is designed to be discarded after consumption and is very inexpensive to initialize.
|
||||
yield return describe.Transient<IMvcRazorHost, MvcRazorHost>();
|
||||
|
||||
services.AddTransient<IMvcRazorHost, MvcRazorHost>();
|
||||
|
||||
// Caches compilation artifacts across the lifetime of the application.
|
||||
yield return describe.Singleton<ICompilerCache, CompilerCache>();
|
||||
services.AddSingleton<ICompilerCache, CompilerCache>();
|
||||
|
||||
// This caches compilation related details that are valid across the lifetime of the application
|
||||
// and is required to be a singleton.
|
||||
yield return describe.Singleton<ICompilationService, RoslynCompilationService>();
|
||||
services.AddSingleton<ICompilationService, RoslynCompilationService>();
|
||||
|
||||
// Both the compiler cache and roslyn compilation service hold on the compilation related
|
||||
// caches. RazorCompilation service is just an adapter service, and it is transient to ensure
|
||||
// the IMvcRazorHost dependency does not maintain state.
|
||||
yield return describe.Transient<IRazorCompilationService, RazorCompilationService>();
|
||||
services.AddTransient<IRazorCompilationService, RazorCompilationService>();
|
||||
|
||||
// The ViewStartProvider needs to be able to consume scoped instances of IRazorPageFactory
|
||||
yield return describe.Scoped<IViewStartProvider, ViewStartProvider>();
|
||||
yield return describe.Transient<IRazorViewFactory, RazorViewFactory>();
|
||||
yield return describe.Singleton<IRazorPageActivator, RazorPageActivator>();
|
||||
services.AddScoped<IViewStartProvider, ViewStartProvider>();
|
||||
services.AddTransient<IRazorViewFactory, RazorViewFactory>();
|
||||
services.AddSingleton<IRazorPageActivator, RazorPageActivator>();
|
||||
|
||||
// Virtual path view factory needs to stay scoped so views can get get scoped services.
|
||||
yield return describe.Scoped<IRazorPageFactory, VirtualPathRazorPageFactory>();
|
||||
services.AddScoped<IRazorPageFactory, VirtualPathRazorPageFactory>();
|
||||
|
||||
// View and rendering helpers
|
||||
yield return describe.Transient<IHtmlHelper, HtmlHelper>();
|
||||
yield return describe.Transient(typeof(IHtmlHelper<>), typeof(HtmlHelper<>));
|
||||
yield return describe.Scoped<IUrlHelper, UrlHelper>();
|
||||
services.AddTransient<IHtmlHelper, HtmlHelper>();
|
||||
services.AddTransient(typeof(IHtmlHelper<>), typeof(HtmlHelper<>));
|
||||
services.AddScoped<IUrlHelper, UrlHelper>();
|
||||
|
||||
// Only want one ITagHelperActivator so it can cache Type activation information. Types won't conflict.
|
||||
yield return describe.Singleton<ITagHelperActivator, DefaultTagHelperActivator>();
|
||||
services.AddSingleton<ITagHelperActivator, DefaultTagHelperActivator>();
|
||||
|
||||
// Consumed by the Cache tag helper to cache results across the lifetime of the application.
|
||||
yield return describe.Singleton<IMemoryCache, MemoryCache>();
|
||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||
|
||||
// DefaultHtmlGenerator is pretty much stateless but depends on Scoped services such as IUrlHelper and
|
||||
// IActionBindingContextProvider. Therefore it too is scoped.
|
||||
yield return describe.Transient<IHtmlGenerator, DefaultHtmlGenerator>();
|
||||
services.AddTransient<IHtmlGenerator, DefaultHtmlGenerator>();
|
||||
|
||||
// These do caching so they should stay singleton
|
||||
yield return describe.Singleton<IViewComponentSelector, DefaultViewComponentSelector>();
|
||||
yield return describe.Singleton<IViewComponentActivator, DefaultViewComponentActivator>();
|
||||
services.AddSingleton<IViewComponentSelector, DefaultViewComponentSelector>();
|
||||
services.AddSingleton<IViewComponentActivator, DefaultViewComponentActivator>();
|
||||
|
||||
yield return describe.Transient<IViewComponentInvokerFactory, DefaultViewComponentInvokerFactory>();
|
||||
yield return describe.Transient<IViewComponentInvokerProvider, DefaultViewComponentInvokerProvider>();
|
||||
yield return describe.Transient<IViewComponentHelper, DefaultViewComponentHelper>();
|
||||
services.AddTransient<IViewComponentInvokerFactory, DefaultViewComponentInvokerFactory>();
|
||||
services.AddTransient<IViewComponentInvokerProvider, DefaultViewComponentInvokerProvider>();
|
||||
services.AddTransient<IViewComponentHelper, DefaultViewComponentHelper>();
|
||||
|
||||
// Security and Authorization
|
||||
yield return describe.Singleton<IClaimUidExtractor, DefaultClaimUidExtractor>();
|
||||
yield return describe.Singleton<AntiForgery, AntiForgery>();
|
||||
yield return describe.Singleton<IAntiForgeryAdditionalDataProvider,
|
||||
DefaultAntiForgeryAdditionalDataProvider>();
|
||||
services.AddSingleton<IClaimUidExtractor, DefaultClaimUidExtractor>();
|
||||
services.AddSingleton<AntiForgery, AntiForgery>();
|
||||
services.AddSingleton<IAntiForgeryAdditionalDataProvider, DefaultAntiForgeryAdditionalDataProvider>();
|
||||
|
||||
// Api Description
|
||||
yield return describe.Singleton<IApiDescriptionGroupCollectionProvider,
|
||||
ApiDescriptionGroupCollectionProvider>();
|
||||
yield return describe.Transient<IApiDescriptionProvider, DefaultApiDescriptionProvider>();
|
||||
services.AddSingleton<IApiDescriptionGroupCollectionProvider, ApiDescriptionGroupCollectionProvider>();
|
||||
services.AddTransient<IApiDescriptionProvider, DefaultApiDescriptionProvider>();
|
||||
|
||||
// Temp Data
|
||||
yield return describe.Singleton<ITempDataProvider, SessionStateTempDataProvider>();
|
||||
yield return describe.Scoped<ITempDataDictionary, TempDataDictionary>();
|
||||
services.AddSingleton<ITempDataProvider, SessionStateTempDataProvider>();
|
||||
services.AddScoped<ITempDataDictionary, TempDataDictionary>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
|
@ -16,14 +18,22 @@ using Microsoft.Framework.Runtime.Roslyn;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="ICompileModule"/> implementation that pre-compiles Razor views in the application.
|
||||
/// </summary>
|
||||
public abstract class RazorPreCompileModule : ICompileModule
|
||||
{
|
||||
private readonly IServiceProvider _appServices;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new <see cref="RazorPreCompileModule"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceProvider"/> for the application.</param>
|
||||
public RazorPreCompileModule(IServiceProvider services)
|
||||
{
|
||||
_appServices = services;
|
||||
|
||||
// When ListenForMemoryPressure is true, the MemoryCache evicts items at every gen2 collection.
|
||||
// In DTH, gen2 happens frequently enough to make it undesirable for caching precompilation results. We'll
|
||||
// disable listening for memory pressure for the MemoryCache instance used by precompilation.
|
||||
|
|
@ -35,61 +45,95 @@ namespace Microsoft.AspNet.Mvc
|
|||
/// </summary>
|
||||
public bool GenerateSymbols { get; protected set; }
|
||||
|
||||
protected virtual string FileExtension { get; } = ".cshtml";
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>Pre-compiles all Razor views in the application.</remarks>
|
||||
public virtual void BeforeCompile(IBeforeCompileContext context)
|
||||
{
|
||||
var applicationEnvironment = _appServices.GetRequiredService<IApplicationEnvironment>();
|
||||
var compilerOptionsProvider = _appServices.GetRequiredService<ICompilerOptionsProvider>();
|
||||
var compilationSettings = compilerOptionsProvider.GetCompilationSettings(applicationEnvironment);
|
||||
|
||||
var setup = new RazorViewEngineOptionsSetup(applicationEnvironment);
|
||||
var sc = new ServiceCollection();
|
||||
sc.ConfigureOptions(setup);
|
||||
sc.AddMvc();
|
||||
// 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
|
||||
// is an IOptions<RazorViewEngineOptions> but use AddMvc() for simplicity and flexibility.
|
||||
var serviceCollection = HostingServices.Create(_appServices);
|
||||
serviceCollection.AddMvc();
|
||||
|
||||
var serviceProvider = BuildFallbackServiceProvider(sc, _appServices);
|
||||
// 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
|
||||
// this site. For example similar functional test changes to the IApplicationEnvironment happen later,
|
||||
// after everything is compiled. IOptions<RazorViewEngineOptions> setup initializes the
|
||||
// RazorViewEngineOptions based on this IApplicationEnvironment implementation.
|
||||
var directory = context.ProjectContext.ProjectDirectory;
|
||||
var precompilationApplicationEnvironment = new PrecompilationApplicationEnvironment(
|
||||
applicationEnvironment,
|
||||
context.ProjectContext.ProjectDirectory);
|
||||
serviceCollection.AddInstance<IApplicationEnvironment>(precompilationApplicationEnvironment);
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
var viewCompiler = new RazorPreCompiler(serviceProvider, context, _memoryCache, compilationSettings)
|
||||
{
|
||||
GenerateSymbols = GenerateSymbols
|
||||
};
|
||||
|
||||
viewCompiler.CompileViews();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AfterCompile(IAfterCompileContext context)
|
||||
{
|
||||
}
|
||||
|
||||
// TODO: KILL THIS
|
||||
private static IServiceProvider BuildFallbackServiceProvider(
|
||||
IServiceCollection services,
|
||||
IServiceProvider fallback)
|
||||
private class PrecompilationApplicationEnvironment : IApplicationEnvironment
|
||||
{
|
||||
var sc = HostingServices.Create(fallback);
|
||||
sc.Add(services);
|
||||
private readonly IApplicationEnvironment _originalApplicationEnvironment;
|
||||
private readonly string _applicationBasePath;
|
||||
|
||||
// Build the manifest
|
||||
var manifestTypes = services.Where(t => t.ServiceType.GetTypeInfo().GenericTypeParameters.Length == 0
|
||||
&& t.ServiceType != typeof(IServiceManifest)
|
||||
&& t.ServiceType != typeof(IServiceProvider))
|
||||
.Select(t => t.ServiceType).Distinct();
|
||||
sc.AddInstance<IServiceManifest>(
|
||||
new ServiceManifest(manifestTypes, fallback.GetRequiredService<IServiceManifest>()));
|
||||
return sc.BuildServiceProvider();
|
||||
}
|
||||
|
||||
private class ServiceManifest : IServiceManifest
|
||||
{
|
||||
public ServiceManifest(IEnumerable<Type> services, IServiceManifest fallback = null)
|
||||
public PrecompilationApplicationEnvironment(IApplicationEnvironment original, string appBasePath)
|
||||
{
|
||||
Services = services;
|
||||
if (fallback != null)
|
||||
_originalApplicationEnvironment = original;
|
||||
_applicationBasePath = appBasePath;
|
||||
}
|
||||
|
||||
public string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
Services = Services.Concat(fallback.Services).Distinct();
|
||||
return _originalApplicationEnvironment.ApplicationName;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Type> Services { get; private set; }
|
||||
public string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return _originalApplicationEnvironment.Version;
|
||||
}
|
||||
}
|
||||
|
||||
public string ApplicationBasePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return _applicationBasePath;
|
||||
}
|
||||
}
|
||||
|
||||
public string Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return _originalApplicationEnvironment.Configuration;
|
||||
}
|
||||
}
|
||||
|
||||
public FrameworkName RuntimeFramework
|
||||
{
|
||||
get
|
||||
{
|
||||
return _originalApplicationEnvironment.RuntimeFramework;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,30 +2,27 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using ActionResultsWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class ActionResultTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("ActionResultsWebSite");
|
||||
private const string SiteName = nameof(ActionResultsWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task BadRequestResult_CanBeReturned()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{\"SampleInt\":10}";
|
||||
|
||||
|
|
@ -47,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CreatedResult_SetsRelativePathInLocationHeader()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -67,7 +64,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CreatedResult_SetsAbsolutePathInLocationHeader()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -87,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CreatedResult_SetsQualifiedPathInLocationHeader()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -109,7 +106,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CreatedResult_SetsUriInLocationHeader()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -129,7 +126,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CreatedAtActionResult_GeneratesUri_WithActionAndController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -149,7 +146,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CreatedAtRouteResult_GeneratesUri_WithRouteValues()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -169,7 +166,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CreatedAtRouteResult_GeneratesUri_WithRouteName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -189,7 +186,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task SerializableError_CanSerializeNormalObjects()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
|
|
@ -212,7 +209,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ContentResult_WritesContent_SetsDefaultContentTypeAndEncoding()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post,
|
||||
|
|
@ -232,7 +229,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ContentResult_WritesContent_SetsContentTypeWithDefaultEncoding()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post,
|
||||
|
|
@ -252,7 +249,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ContentResult_WritesContent_SetsContentTypeAndEncoding()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post,
|
||||
|
|
@ -272,7 +269,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ObjectResult_WithStatusCodeAndNoContent_SetsSameStatusCode()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Get,
|
||||
|
|
@ -289,7 +286,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task HttpNotFoundObjectResult_NoResponseContent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -308,7 +305,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task HttpNotFoundObjectResult_WithResponseContent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{\"SampleInt\":10}";
|
||||
|
||||
|
|
|
|||
|
|
@ -5,21 +5,20 @@ using System;
|
|||
using System.Threading.Tasks;
|
||||
using ActivatorWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class ActivatorTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("ActivatorWebSite");
|
||||
private const string SiteName = nameof(ActivatorWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ControllerThatCannotBeActivated_ThrowsWhenAttemptedToBeInvoked()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expectedMessage = "The property 'Service' on controller 'ActivatorWebSite.CannotBeActivatedController' " +
|
||||
|
|
@ -37,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PropertiesForPocoControllersAreInitialized()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = "4|some-text";
|
||||
|
||||
|
|
@ -55,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PropertiesForTypesDerivingFromControllerAreInitialized()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = "Hello world";
|
||||
|
||||
|
|
@ -70,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewActivator_ActivatesDefaultInjectedProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = @"<label for=""Hello"">Hello</label> world! /View/ConsumeServicesFromBaseType";
|
||||
|
||||
|
|
@ -85,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewActivator_ActivatesAndContextualizesInjectedServices()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = "4 test-value";
|
||||
|
||||
|
|
@ -100,7 +99,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewActivator_ActivatesServicesFromBaseType()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = @"/content/scripts/test.js";
|
||||
|
||||
|
|
@ -115,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewComponentActivator_ActivatesProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = @"Random Number:4";
|
||||
|
||||
|
|
@ -130,7 +129,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewComponentActivator_ActivatesPropertiesAndContextualizesThem()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = "test-value";
|
||||
|
||||
|
|
@ -145,7 +144,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewComponentActivator_ActivatesPropertiesAndContextualizesThem_WhenMultiplePropertiesArePresent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = "Random Number:4 test-value";
|
||||
|
||||
|
|
@ -160,7 +159,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewComponentThatCannotBeActivated_ThrowsWhenAttemptedToBeInvoked()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedMessage = "No service for type 'ActivatorWebSite.CannotBeActivatedComponent+FakeType' " +
|
||||
"has been registered.";
|
||||
|
|
@ -177,7 +176,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TagHelperActivation_ActivateHtmlHelper_RendersProperly()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expected = "<body><h2>Activation Test</h2>" +
|
||||
Environment.NewLine +
|
||||
|
|
|
|||
|
|
@ -8,21 +8,20 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class AntiForgeryTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("AntiForgeryWebSite");
|
||||
private const string SiteName = nameof(AntiForgeryWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new AntiForgeryWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task MultipleAFTokensWithinTheSamePage_GeneratesASingleCookieToken()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -45,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MultipleFormPostWithingASingleView_AreAllowed()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// do a get response.
|
||||
|
|
@ -80,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task InvalidCookieToken_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var getResponse = await client.GetAsync("http://localhost/Account/Login");
|
||||
|
|
@ -112,7 +111,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task InvalidFormToken_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var getResponse = await client.GetAsync("http://localhost/Account/Login");
|
||||
|
|
@ -142,7 +141,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task IncompatibleCookieToken_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// do a get response.
|
||||
|
|
@ -180,7 +179,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MissingCookieToken_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// do a get response.
|
||||
|
|
@ -210,7 +209,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MissingAFToken_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var getResponse = await client.GetAsync("http://localhost/Account/Login");
|
||||
var resposneBody = await getResponse.Content.ReadAsStringAsync();
|
||||
|
|
@ -239,7 +238,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task SetCookieAndHeaderBeforeFlushAsync_GeneratesCookieTokenAndHeader()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -259,7 +258,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task SetCookieAndHeaderBeforeFlushAsync_PostToForm()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// do a get response.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -16,14 +15,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ApiExplorerTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("ApiExplorerWebSite");
|
||||
private const string SiteName = nameof(ApiExplorerWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new ApiExplorerWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ApiExplorer_IsVisible_EnabledWithConvention()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -40,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_IsVisible_DisabledWithConvention()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -57,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_IsVisible_DisabledWithAttribute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -74,7 +73,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_IsVisible_EnabledWithAttribute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -91,7 +90,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_GroupName_SetByConvention()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -109,7 +108,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_GroupName_SetByAttributeOnController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -127,7 +126,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_GroupName_SetByAttributeOnAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -145,7 +144,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplate_DisplaysFixedRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -163,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplate_DisplaysRouteWithParameters()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -187,7 +186,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplate_StripsInlineConstraintsFromThePath()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/Constraint/5";
|
||||
|
||||
|
|
@ -212,7 +211,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplate_StripsCatchAllsFromThePath()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/CatchAll/5";
|
||||
|
||||
|
|
@ -236,7 +235,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplate_StripsCatchAllsWithConstraintsFromThePath()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/CatchAllAndConstraint/5";
|
||||
|
||||
|
|
@ -263,7 +262,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplateStripsMultipleConstraints_OnTheSamePathSegment()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/"
|
||||
|
|
@ -302,7 +301,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplateStripsMultipleConstraints_InMultipleSegments()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/"
|
||||
+ "MultipleParametersInMultipleSegments/12/01/1987";
|
||||
|
|
@ -340,7 +339,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_DescribeParameters_FromAllSources()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/ApiExplorerRouteAndPathParametersInformation/MultipleTypesOfParameters/1/2/3";
|
||||
|
||||
|
|
@ -371,7 +370,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_RouteTemplate_MakesParametersOptional()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -393,7 +392,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_HttpMethod_All()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -411,7 +410,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_HttpMethod_Single()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -433,7 +432,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_HttpMethod_Single(string httpMethod)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -459,7 +458,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseType_VoidWithoutAttribute(string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -484,7 +483,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseType_UnknownWithoutAttribute(string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -507,7 +506,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseType_KnownWithoutAttribute(string action, string type)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -531,7 +530,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseType_KnownWithAttribute(string action, string type)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -552,7 +551,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseType_OverrideOnAction(string action, string type)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -571,7 +570,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseContentType_Unset()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -601,7 +600,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseContentType_Specific()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -627,7 +626,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ResponseContentType_NoMatch()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -652,7 +651,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string formatterType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -674,7 +673,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_Parameters_SimpleTypes_Default()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -702,7 +701,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_Parameters_SimpleTypes_BinderMetadataOnParameters()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -730,7 +729,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_ParametersSimpleModel()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -754,7 +753,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_Parameters_SimpleTypes_SimpleModel_FromBody()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -782,7 +781,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiExplorer_Parameters_SimpleTypes_ComplexModel()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -6,21 +6,20 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class ApplicationModelTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ApplicationModelWebSite));
|
||||
private const string SiteName = nameof(ApplicationModelWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new ApplicationModelWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ControllerModel_CustomizedWithAttribute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -37,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionModel_CustomizedWithAttribute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -54,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ParameterModel_CustomizedWithAttribute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -71,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApplicationModel_AddPropertyToActionDescriptor_FromApplicationModel()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -88,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApplicationModel_AddPropertyToActionDescriptor_ControllerModelOverwritesCommonApplicationProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -105,7 +104,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApplicationModel_ProvidesMetadataToActionDescriptor_ActionModelOverwritesControllerModelProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -122,7 +121,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApplicationModelExtensions_AddsConventionToAllControllers()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -141,7 +140,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApplicationModelExtensions_AddsConventionToAllActions()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/GetHelloWorld");
|
||||
|
|
@ -149,7 +148,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
// Act
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
|
|
@ -11,7 +10,6 @@ using System.Reflection;
|
|||
using System.Threading.Tasks;
|
||||
using BasicWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -19,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class BasicTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(BasicWebSite));
|
||||
private const string SiteName = nameof(BasicWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
// Some tests require comparing the actual response body against an expected response baseline
|
||||
|
|
@ -35,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanRender_ViewsWithLayout(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||
|
||||
|
|
@ -59,7 +57,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanRender_SimpleViews()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync("compiler/resources/BasicWebSite.Home.PlainView.html");
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||
|
|
@ -79,7 +77,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanReturn_ResultsWithoutContent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -97,7 +95,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ReturningTaskFromAction_ProducesNoContentResult()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -112,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionDescriptors_CreatedOncePerRequest()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expectedContent = "1";
|
||||
|
|
@ -132,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionWithRequireHttps_RedirectsToSecureUrl_ForNonHttpsGetRequests()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -152,7 +150,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionWithRequireHttps_ReturnsBadRequestResponse_ForNonHttpsNonGetRequests()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -174,7 +172,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionWithRequireHttps_AllowsHttpsRequests(string method)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = new HttpClient(server.CreateHandler(), false);
|
||||
|
||||
// Act
|
||||
|
|
@ -190,7 +188,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonViewComponent_RendersJson()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = new HttpClient(server.CreateHandler(), false);
|
||||
var expectedBody = JsonConvert.SerializeObject(new BasicWebSite.Models.Person()
|
||||
{
|
||||
|
|
@ -249,7 +247,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task HtmlHelperLinkGeneration(string viewName, string expectedLink)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = new HttpClient(server.CreateHandler(), false);
|
||||
|
||||
// Act
|
||||
|
|
@ -265,7 +263,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConfigureMvcOptionsAddsOptionsProperly()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = new HttpClient(server.CreateHandler(), false);
|
||||
|
||||
// Act
|
||||
|
|
@ -281,7 +279,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypesWithoutControllerSuffix_DerivingFromTypesWithControllerSuffix_CanBeAccessed()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = new HttpClient(server.CreateHandler(), false);
|
||||
|
||||
// Act
|
||||
|
|
@ -295,7 +293,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypesMarkedAsNonAction_AreInaccessible()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = new HttpClient(server.CreateHandler(), false);
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
|
|
@ -14,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
public class BestEffortLinkGenerationTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(BestEffortLinkGenerationWebSite));
|
||||
private const string SiteName = nameof(BestEffortLinkGenerationWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new BestEffortLinkGenerationWebSite.Startup().Configure;
|
||||
|
||||
private const string ExpectedOutput = @"<html>
|
||||
|
|
@ -27,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GenerateLink_NonExistentAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/Home/Index";
|
||||
|
|
@ -39,6 +38,5 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(ExpectedOutput, content);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using RazorWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -15,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// precompiled and dynamically compiled views.
|
||||
public class CompilationOptionsTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(RazorWebSite));
|
||||
private const string SiteName = nameof(RazorWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
|
|
@ -33,7 +31,7 @@ This method is only defined in DNX451";
|
|||
|
||||
This method is only defined in DNXCORE50";
|
||||
#endif
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -4,21 +4,20 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class CompositeViewEngineTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(CompositeViewEngineWebSite));
|
||||
private const string SiteName = nameof(CompositeViewEngineWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new CompositeViewEngineWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task CompositeViewEngine_FindsPartialViewsAcrossAllEngines()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -32,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CompositeViewEngine_FindsViewsAcrossAllEngines()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -2,16 +2,12 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using ActionConstraintsWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -19,14 +15,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ConsumesAttributeTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("ActionConstraintsWebSite");
|
||||
private const string SiteName = nameof(ActionConstraintsWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task NoRequestContentType_SelectsActionWithoutConstraint()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post,
|
||||
|
|
@ -45,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoRequestContentType_Throws_IfMultipleActionsWithConstraints()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post,
|
||||
|
|
@ -69,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoRequestContentType_Selects_IfASingleActionWithConstraintIsPresent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -91,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task Selects_Action_BasedOnRequestContentType(string requestContentType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var input = "{SampleString:\""+requestContentType+"\"}";
|
||||
|
|
@ -114,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionLevelAttribute_OveridesClassLevel(string requestContentType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var input = "{SampleString:\"" + requestContentType + "\"}";
|
||||
|
|
@ -137,7 +133,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task DerivedClassLevelAttribute_OveridesBaseClassLevel()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var input = "<Product xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
||||
|
|
|
|||
|
|
@ -2,18 +2,13 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using ContentNegotiationWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -21,14 +16,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ContentNegotiationTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(ContentNegotiationWebSite));
|
||||
private const string SiteName = nameof(ContentNegotiationWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ProducesAttribute_SingleContentType_PicksTheFirstSupportedFormatter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Selects custom even though it is last in the list.
|
||||
|
|
@ -48,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ProducesAttribute_MultipleContentTypes_RunsConnegToSelectFormatter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
var expectedBody = "{\r\n \"Name\": \"My name\",\r\n \"Address\": \"My address\"\r\n}";
|
||||
|
|
@ -66,7 +61,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoProducesAttribute_ActionReturningString_RunsUsingTextFormatter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("text/plain;charset=utf-8");
|
||||
var expectedBody = "NormalController";
|
||||
|
|
@ -84,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoProducesAttribute_ActionReturningAnyObject_RunsUsingDefaultFormatters()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
|
||||
|
|
@ -99,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ProducesAttributeWithTypeOnly_RunsRegularContentNegotiation()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
|
|
@ -119,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ProducesAttribute_WithTypeAndContentType_UsesContentType()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/xml;charset=utf-8");
|
||||
|
|
@ -141,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoMatchingFormatter_ForTheGivenContentType_Returns406()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -160,7 +155,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string expectedResponseBody)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
expectedResponseBody = expectedResponseBody.Replace("#", Environment.NewLine);
|
||||
|
||||
|
|
@ -181,7 +176,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ProducesAttribute_OnAction_OverridesTheValueOnClass()
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Value on the class is application/json.
|
||||
|
|
@ -201,7 +196,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ProducesAttribute_OnDerivedClass_OverridesTheValueOnBaseClass()
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse(
|
||||
"application/custom_ProducesContentOnClassController;charset=utf-8");
|
||||
|
|
@ -220,7 +215,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseClass()
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse(
|
||||
"application/custom_NoProducesContentOnClassController_Action;charset=utf-8");
|
||||
|
|
@ -238,7 +233,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseAction()
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse(
|
||||
"application/custom_NoProducesContentOnClassController_Action;charset=utf-8");
|
||||
|
|
@ -257,7 +252,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ProducesAttribute_OnDerivedClassAndAction_OverridesTheValueOnBaseClass()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse(
|
||||
"application/custom_ProducesContentOnClassController_Action;charset=utf-8");
|
||||
|
|
@ -276,7 +271,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ProducesAttribute_IsNotHonored_ForJsonResult()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
var expectedBody = "{\"MethodName\":\"Produces_WithNonObjectResult\"}";
|
||||
|
|
@ -294,7 +289,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_UsesDefaultContentTypes_IfNoneAreAddedExplicitly()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
var expectedBody = "{\"MethodName\":\"ReturnJsonResult\"}";
|
||||
|
|
@ -312,7 +307,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_UsesExplicitContentTypeAndFormatter_IfAdded()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/custom-json;charset=utf-8");
|
||||
var expectedBody = "{ MethodName = ReturnJsonResult_WithCustomMediaType }";
|
||||
|
|
@ -330,7 +325,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_UsesDefaultJsonFormatter_IfNoMatchingFormatterIsFound()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
var expectedBody = "{\"MethodName\":\"ReturnJsonResult_WithCustomMediaType_NoFormatter\"}";
|
||||
|
|
@ -348,7 +343,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonFormatter_SupportedMediaType_DoesNotChangeAcrossRequests()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
var expectedBody = "{\"MethodName\":\"ReturnJsonResult\"}";
|
||||
|
|
@ -368,7 +363,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task XmlFormatter_SupportedMediaType_DoesNotChangeAcrossRequests()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
|
||||
client.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));
|
||||
|
|
@ -394,7 +389,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoMatchOn_RequestContentType_FallsBackOnTypeBasedMatch_MatchFound(string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
var expectedBody = "1234";
|
||||
|
|
@ -419,7 +414,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoMatchOn_RequestContentType_SkipTypeMatchByAddingACustomFormatter(string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var targetUri = "http://localhost/FallbackOnTypeBasedMatch/" + actionName + "/?input=1234";
|
||||
var content = new StringContent("1234", Encoding.UTF8, "application/custom");
|
||||
|
|
@ -438,7 +433,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoMatchOn_RequestContentType_FallsBackOnTypeBasedMatch_NoMatchFound_Returns406()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var targetUri = "http://localhost/FallbackOnTypeBasedMatch/FallbackGivesNoMatch/?input=1234";
|
||||
var content = new StringContent("1234", Encoding.UTF8, "application/custom");
|
||||
|
|
@ -457,7 +452,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ProducesAttribute_And_FormatFilterAttribute_Conflicting()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json");
|
||||
|
||||
|
|
@ -472,7 +467,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ProducesAttribute_And_FormatFilterAttribute_Collaborating()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ using System.Net;
|
|||
using System.Threading.Tasks;
|
||||
using ControllerDiscoveryConventionsWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Xunit;
|
||||
|
|
@ -18,15 +16,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ControllerDiscoveryConventionTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(
|
||||
nameof(ControllerDiscoveryConventionsWebSite));
|
||||
private const string SiteName = nameof(ControllerDiscoveryConventionsWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task AbstractControllers_AreSkipped()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost/");
|
||||
|
||||
|
|
@ -41,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypesDerivingFromControllerBaseTypesThatDoNotReferenceMvc_AreSkipped()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost/");
|
||||
|
||||
|
|
@ -56,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypesMarkedWithNonController_AreSkipped()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost/");
|
||||
|
||||
|
|
@ -71,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PocoTypesWithControllerSuffix_AreDiscovered()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost/");
|
||||
|
||||
|
|
@ -87,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypesDerivingFromTypesWithControllerSuffix_AreDiscovered()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost/");
|
||||
|
||||
|
|
@ -103,13 +100,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypesDerivingFromApiController_AreDiscovered()
|
||||
{
|
||||
// Arrange
|
||||
// TestHelper.CreateServices replaces the DefaultAssemblyProvider with a provider that
|
||||
// TestHelper.CreateServer normally replaces the DefaultAssemblyProvider with a provider that
|
||||
// limits the set of candidate assemblies to the executing application. For this test,
|
||||
// we'll switch it back to using a filtered default assembly provider.
|
||||
var services = HostingServices.Create();
|
||||
services.AddTransient<IAssemblyProvider, FilteredDefaultAssemblyProvider>();
|
||||
var serviceProvider = TestHelper.CreateServices(nameof(ControllerDiscoveryConventionsWebSite), services);
|
||||
var server = TestServer.Create(serviceProvider, _app);
|
||||
var server = TestHelper.CreateServer(
|
||||
_app,
|
||||
SiteName,
|
||||
services => services.AddTransient<IAssemblyProvider, FilteredDefaultAssemblyProvider>());
|
||||
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost/");
|
||||
|
|
|
|||
|
|
@ -7,15 +7,13 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using ControllersFromServicesWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class ControllerFromServicesTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(
|
||||
nameof(ControllersFromServicesWebSite));
|
||||
private const string SiteName = nameof(ControllersFromServicesWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
|
|
@ -23,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = "/constructorinjection 14 test-header-value";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.TryAddWithoutValidation("Test-Header", "test-header-value");
|
||||
|
||||
|
|
@ -39,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = "No schedules available for 23";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -54,7 +52,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = "4";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -69,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = "Updated record employee303";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -86,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = "Saved record employee #211";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -106,7 +104,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AddControllersFromServices_UsesControllerDiscoveryContentions(string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -2,20 +2,17 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class CustomRouteTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(CustomRouteWebSite));
|
||||
private const string SiteName = nameof(CustomRouteWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new CustomRouteWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -25,7 +22,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RouteToLocale_ConventionalRoute_BasedOnUser(string user, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/CustomRoute_Products/Index");
|
||||
|
|
@ -47,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RouteWithAttributeRoute_IncludesLocale_BasedOnUser(string user, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/CustomRoute_Orders/5");
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
|
|
@ -19,46 +18,40 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
/// </summary>
|
||||
public class CustomUrlHelperTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("UrlHelperWebSite");
|
||||
private const string SiteName = nameof(UrlHelperWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new UrlHelperWebSite.Startup().Configure;
|
||||
private const string _cdnServerBaseUrl = "http://cdn.contoso.com";
|
||||
|
||||
[Fact]
|
||||
public async Task CustomUrlHelper_GeneratesUrlFromController()
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Home/UrlContent");
|
||||
var responseData = await response.Content.ReadAsStringAsync();
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Home/UrlContent");
|
||||
var responseData = await response.Content.ReadAsStringAsync();
|
||||
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(_cdnServerBaseUrl + "/bootstrap.min.css", responseData);
|
||||
}
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(_cdnServerBaseUrl + "/bootstrap.min.css", responseData);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CustomUrlHelper_GeneratesUrlFromView()
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Home/Index");
|
||||
var responseData = await response.Content.ReadAsStringAsync();
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Home/Index");
|
||||
var responseData = await response.Content.ReadAsStringAsync();
|
||||
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Contains(_cdnServerBaseUrl + "/bootstrap.min.css", responseData);
|
||||
}
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Contains(_cdnServerBaseUrl + "/bootstrap.min.css", responseData);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -66,20 +59,17 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[InlineData("http://localhost/Home/LinkByUrlAction", "/home/urlcontent")]
|
||||
public async Task LowercaseUrls_LinkGeneration(string url, string expectedLink)
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync(url);
|
||||
var responseData = await response.Content.ReadAsStringAsync();
|
||||
// Act
|
||||
var response = await client.GetAsync(url);
|
||||
var responseData = await response.Content.ReadAsStringAsync();
|
||||
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(expectedLink, responseData, ignoreCase: false);
|
||||
}
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(expectedLink, responseData, ignoreCase: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@ using Microsoft.AspNet.Mvc.Core;
|
|||
using Microsoft.AspNet.Mvc.Description;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.AspNet.Mvc.ViewComponents;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -19,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Tests that various MVC services have the correct order.
|
||||
public class DefaultOrderTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(BasicWebSite));
|
||||
private const string SiteName = nameof(BasicWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -34,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ServiceOrder_GetOrder(Type serviceType, Type actualType, int order)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/Order/GetServiceOrder?serviceType=" + serviceType.AssemblyQualifiedName;
|
||||
|
|
|
|||
|
|
@ -3,29 +3,26 @@
|
|||
|
||||
#if DNX451
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using AutofacWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class DependencyResolverTests
|
||||
{
|
||||
private const string SiteName = nameof(AutofacWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
[InlineData("http://localhost/di", "<p>Builder Output: Hello from builder.</p>")]
|
||||
[InlineData("http://localhost/basic", "<p>Hello From Basic View</p>")]
|
||||
public async Task AutofacDIContainerCanUseMvc(string url, string expectedResponseBody)
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestHelper.CreateServices("AutofacWebSite");
|
||||
Action<IApplicationBuilder> app = new Startup().Configure;
|
||||
|
||||
// Act & Assert (does not throw)
|
||||
// Arrange & Act & Assert (does not throw)
|
||||
// This essentially calls into the Startup.Configuration method
|
||||
var server = TestServer.Create(provider, app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
|
||||
// Make a request to start resolving DI pieces
|
||||
var response = await server.CreateClient().GetAsync(url);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using RazorWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -12,14 +11,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class DirectivesTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("RazorWebSite");
|
||||
private const string SiteName = nameof(RazorWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ViewsInheritsUsingsAndInjectDirectivesFromViewStarts()
|
||||
{
|
||||
var expected = @"Hello Person1";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -33,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ViewInheritsBasePageFromViewStarts()
|
||||
{
|
||||
var expected = @"WriteLiteral says:layout:Write says:Write says:Hello Person2";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Reflection;
|
|||
using System.Threading.Tasks;
|
||||
using ErrorPageMiddlewareWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
|
|
@ -18,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
/// </summary>
|
||||
public class ErrorPageTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(ErrorPageMiddlewareWebSite));
|
||||
private const string SiteName = nameof(ErrorPageMiddlewareWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
private readonly Assembly _resourcesAssembly = typeof(ErrorPageTests).GetTypeInfo().Assembly;
|
||||
|
||||
|
|
@ -32,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CompilationFailuresAreListedByErrorPageMiddleware(string action, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,21 +5,20 @@ using System;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class FileResultTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("FilesWebSite");
|
||||
private const string SiteName = nameof(FilesWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FilesWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task FileFromDisk_CanBeEnabled_WithMiddleware()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -40,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FileFromDisk_ReturnsFileWithFileName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -65,7 +64,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FileFromStream_ReturnsFile()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -86,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FileFromStream_ReturnsFileWithFileName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -111,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FileFromBinaryData_ReturnsFile()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -132,7 +131,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FileFromBinaryData_ReturnsFileWithFileName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -9,14 +9,13 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class FiltersTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("FiltersWebSite");
|
||||
private const string SiteName = nameof(FiltersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FiltersWebSite.Startup().Configure;
|
||||
|
||||
// A controller can only be an action filter and result filter, so we don't have entries
|
||||
|
|
@ -25,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ListAllFilters()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected = new string[]
|
||||
|
|
@ -81,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AnonymousUsersAreBlocked()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -95,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AllowsAnonymousUsersToAccessController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -114,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanAuthorize(string testAction)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -130,7 +129,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AllowAnonymousOverridesAuthorize()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -146,7 +145,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ImpossiblePolicyFailsAuthorize()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -161,7 +160,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ServiceFilterUsesRegisteredServicesAsFilter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -176,7 +175,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ServiceFilterThrowsIfServiceIsNotRegistered()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/RandomNumber/GetAuthorizedRandomNumber";
|
||||
|
||||
|
|
@ -192,7 +191,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypeFilterInitializesArguments()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/RandomNumber/GetModifiedRandomNumber?randomNumber=10";
|
||||
|
||||
|
|
@ -208,7 +207,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TypeFilterThrowsIfServicesAreNotRegistered()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/RandomNumber/GetHalfOfModifiedRandomNumber?randomNumber=3";
|
||||
|
||||
|
|
@ -224,7 +223,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionFilterOverridesActionExecuted()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -241,7 +240,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResultFilterOverridesOnResultExecuting()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -258,7 +257,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResultFilterOverridesOnResultExecuted()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -275,7 +274,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task OrderOfExecutionOfFilters_WhenOrderAttribute_IsNotMentioned()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -293,7 +292,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ExceptionsHandledInActionFilters_WillNotShortCircuitResultFilters()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -310,7 +309,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ExceptionFilter_OnAction_ShortCircuitsResultFilters()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -329,7 +328,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GlobalExceptionFilter_HandlesAnException()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -346,7 +345,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ExceptionFilter_Scope()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -367,7 +366,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionFilter_Scope()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -394,7 +393,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResultFilter_Scope()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -417,7 +416,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FiltersWithOrder()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -434,7 +433,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionFiltersWithOrder()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -455,7 +454,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResultFiltersWithOrder()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -474,7 +473,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionFilterShortCircuitsAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -491,7 +490,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResultFilterShortCircuitsResult()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -508,7 +507,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ExceptionFilterShortCircuitsAnotherExceptionFilter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -525,7 +524,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ThrowingFilters_ResultFilter_NotHandledByGlobalExceptionFilter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -542,7 +541,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ThrowingFilters_ActionFilter_HandledByGlobalExceptionFilter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -559,7 +558,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ThrowingFilters_AuthFilter_NotHandledByGlobalExceptionFilter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -576,7 +575,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ThrowingExceptionFilter_ExceptionFilter_NotHandledByGlobalExceptionFilter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -593,7 +592,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var input = "{ sampleInt: 10 }";
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Json");
|
||||
|
|
@ -601,7 +600,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
// Act
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal("10", await response.Content.ReadAsStringAsync());
|
||||
|
|
@ -618,7 +617,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
// There's nothing that can deserialize the body, so the result contains the default
|
||||
// value.
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Json");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.IO;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using RazorWebSite;
|
||||
using Xunit;
|
||||
|
|
@ -15,15 +14,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class FlushPointTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("RazorWebSite");
|
||||
private const string SiteName = nameof(RazorWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task FlushPointsAreExecutedForPagesWithLayouts()
|
||||
{
|
||||
var waitService = new WaitService();
|
||||
var serviceProvider = GetServiceProvider(waitService);
|
||||
var server = TestServer.Create(serviceProvider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService));
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -46,9 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FlushPointsAreExecutedForPagesWithoutLayouts()
|
||||
{
|
||||
var waitService = new WaitService();
|
||||
var serviceProvider = GetServiceProvider(waitService);
|
||||
|
||||
var server = TestServer.Create(serviceProvider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService));
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -65,7 +61,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Assert - 3
|
||||
Assert.Equal("Inside partial", GetTrimmedString(stream));
|
||||
waitService.WaitForServer();
|
||||
|
||||
|
||||
// Assert - 4
|
||||
Assert.Equal(@"After flush inside partial
|
||||
<form action=""/FlushPoint/PageWithoutLayout"" method=""post""><input id=""Name1"" name=""Name1"" type=""text"" value="""" />",
|
||||
|
|
@ -83,9 +79,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FlushPointsAreExecutedForPagesWithComponentsPartialsAndSections(string action, string title)
|
||||
{
|
||||
var waitService = new WaitService();
|
||||
var serviceProvider = GetServiceProvider(waitService);
|
||||
|
||||
var server = TestServer.Create(serviceProvider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService));
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -121,9 +115,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var waitService = new WaitService();
|
||||
var serviceProvider = GetServiceProvider(waitService);
|
||||
|
||||
var server = TestServer.Create(serviceProvider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService));
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -144,9 +136,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FlushBeforeCallingLayout()
|
||||
{
|
||||
var waitService = new WaitService();
|
||||
var serviceProvider = GetServiceProvider(waitService);
|
||||
|
||||
var server = TestServer.Create(serviceProvider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(waitService));
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expectedMessage = "A layout page cannot be rendered after 'FlushAsync' has been invoked.";
|
||||
|
|
@ -169,13 +159,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
private IServiceProvider GetServiceProvider(WaitService waitService)
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddInstance(waitService);
|
||||
return TestHelper.CreateServices("RazorWebSite", services);
|
||||
}
|
||||
|
||||
private string GetTrimmedString(Stream stream)
|
||||
{
|
||||
var buffer = new byte[1024];
|
||||
|
|
|
|||
|
|
@ -5,21 +5,20 @@ using System;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class FormatFilterTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(FormatFilterWebSite));
|
||||
private const string SiteName = nameof(FormatFilterWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FormatFilterWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task FormatFilter_NoExtensionInRequest()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -34,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_ExtensionInRequest_Default()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_ExtensionInRequest_Optional()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -64,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_ExtensionInRequest_Custom()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -79,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_ExtensionInRequest_CaseInsensitivity()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -94,7 +93,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_ExtensionInRequest_NonExistant()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -108,7 +107,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_And_ProducesFilter_Match()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -123,7 +122,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_And_ProducesFilter_Conflict()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -137,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormatFilter_And_OverrideProducesFilter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using InlineConstraints;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -16,14 +15,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class InlineConstraintTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("InlineConstraintsWebSite");
|
||||
private const string SiteName = nameof(InlineConstraintsWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task RoutingToANonExistantArea_WithExistConstraint_RoutesToCorrectAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -39,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RoutingToANonExistantArea_WithoutExistConstraint_RoutesToIncorrectAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -57,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductById_IntConstraintForOptionalId_IdPresent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -76,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductById_IntConstraintForOptionalId_NoId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -93,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductById_IntConstraintForOptionalId_NotIntId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -107,7 +106,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByName_AlphaContraintForMandatoryName_ValidName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -125,7 +124,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByName_AlphaContraintForMandatoryName_NonAlphaName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -139,7 +138,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByName_AlphaContraintForMandatoryName_NoName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -153,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByManufacturingDate_DateTimeConstraintForMandatoryDateTime_ValidDateTime()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -173,7 +172,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByCategoryName_StringLengthConstraint_ForOptionalCategoryName_ValidCatName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -191,7 +190,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByCategoryName_StringLengthConstraint_ForOptionalCategoryName_InvalidCatName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -206,7 +205,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByCategoryName_StringLength1To20Constraint_ForOptionalCategoryName_NoCatName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -223,7 +222,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_ValidId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -241,7 +240,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_InvalidId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -255,7 +254,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByCategoryId_Int10To100Constraint_ForMandatoryCatId_NotIntId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -269,7 +268,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByPrice_FloatContraintForOptionalPrice_Valid()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -287,7 +286,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByPrice_FloatContraintForOptionalPrice_NoPrice()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -304,7 +303,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByManufacturerId_IntMin10Constraint_ForOptionalManufacturerId_Valid()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -322,7 +321,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetProductByManufacturerId_IntMin10Cinstraint_ForOptionalManufacturerId_NoId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -339,7 +338,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetUserByName_RegExConstraint_ForMandatoryName_Valid()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -357,7 +356,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetUserByName_RegExConstraint_ForMandatoryName_InValid()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -371,7 +370,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetStoreById_GuidConstraintForOptionalId_Valid()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -390,7 +389,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetStoreById_GuidConstraintForOptionalId_NoId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -407,7 +406,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetStoreById_GuidConstraintForOptionalId_NotGuidId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -421,7 +420,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_Valid()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -439,7 +438,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_MoreLength()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -453,7 +452,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_LessLength()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -467,7 +466,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GetStoreByLocation_StringLengthConstraint_AlphaConstraint_ForMandatoryLocation_NoAlpha()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -624,7 +623,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string expectedLink)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Net.Http.Headers;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -16,14 +15,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class InputFormatterTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("FormatterWebSite");
|
||||
private const string SiteName = nameof(FormatterWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task CheckIfXmlInputFormatterIsBeingCalled()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var sampleInputInt = 10;
|
||||
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
|
|
@ -48,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonInputFormatter_IsSelectedForJsonRequest(string requestContentType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var sampleInputInt = 10;
|
||||
var input = "{\"SampleInt\":10}";
|
||||
|
|
@ -80,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
var actionName = filterHandlesModelStateError ? "ActionFilterHandlesError" : "ActionHandlesError";
|
||||
var expectedSource = filterHandlesModelStateError ? "filter" : "action";
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{\"SampleInt\":10}";
|
||||
var content = new StringContent(input);
|
||||
|
|
@ -111,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonInputFormatter_IsModelStateValid_ForValidContentType(string requestContentType, string jsonInput, int expectedSampleIntValue)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType);
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonInputFormatter_IsModelStateInvalid_ForEmptyContentType(string jsonInput)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent(jsonInput, Encoding.UTF8, "application/json");
|
||||
content.Headers.Clear();
|
||||
|
|
@ -150,7 +149,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonInputFormatter_IsModelStateValid_ForTransferEncodingChunk(string requestContentType, string jsonInput, int expectedSampleIntValue)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent(jsonInput, Encoding.UTF8, requestContentType);
|
||||
client.DefaultRequestHeaders.TransferEncodingChunked = true;
|
||||
|
|
@ -170,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CustomFormatter_IsSelected_ForSupportedContentTypeAndEncoding(string encoding)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent("Test Content", Encoding.GetEncoding(encoding), "text/plain");
|
||||
|
||||
|
|
@ -189,7 +188,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CustomFormatter_NotSelected_ForUnsupportedContentType(string contentType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent("Test Content", Encoding.UTF8, contentType);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Net.Http;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
|
@ -18,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class InputObjectValidationTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("FormatterWebSite");
|
||||
private const string SiteName = nameof(FormatterWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
|
||||
|
||||
// Parameters: Request Content, Expected status code, Expected model state error message
|
||||
|
|
@ -47,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CheckIfObjectIsDeserializedWithoutErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var sampleId = 2;
|
||||
var sampleName = "SampleUser";
|
||||
|
|
@ -74,7 +73,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CheckIfObjectIsDeserialized_WithErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var sampleId = 0;
|
||||
var sampleName = "user";
|
||||
|
|
@ -101,7 +100,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CheckIfExcludedFieldsAreNotValidated()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent("{\"Alias\":\"xyz\"}", Encoding.UTF8, "application/json");
|
||||
|
||||
|
|
@ -118,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ShallowValidation_HappensOnExcluded_ComplexTypeProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var requestData = "{\"Name\":\"Library Manager\", \"Suppliers\": [{\"Name\":\"Contoso Corp\"}]}";
|
||||
var content = new StringContent(requestData, Encoding.UTF8, "application/json");
|
||||
|
|
@ -151,7 +150,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string expectedModelStateErrorMessage)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent(requestContent, Encoding.UTF8, "application/json");
|
||||
|
||||
|
|
@ -173,12 +172,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CheckIfExcludedField_IsValidatedForNonBodyBoundModels()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var kvps = new List<KeyValuePair<string, string>>();
|
||||
kvps.Add(new KeyValuePair<string, string>("Alias", "xyz"));
|
||||
var content = new FormUrlEncodedContent(kvps);
|
||||
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsync("http://localhost/Validation/GetDeveloperAlias", content);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Net.Http.Headers;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class JsonOutputFormatterTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("FormatterWebSite");
|
||||
private const string SiteName = nameof(FormatterWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
|
|
@ -36,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
serializerSettings.Formatting = Formatting.Indented;
|
||||
var expectedBody = JsonConvert.SerializeObject(user, serializerSettings);
|
||||
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -51,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task SerializableErrorIsReturnedInExpectedFormat()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class JsonResultTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(BasicWebSite));
|
||||
private const string SiteName = nameof(BasicWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -22,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_Conneg(string mediaType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/JsonResult/Plain";
|
||||
|
|
@ -48,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_Conneg_Fails(string mediaType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/JsonResult/Plain";
|
||||
|
|
@ -71,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_Null()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/JsonResult/Null";
|
||||
|
|
@ -93,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_String()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/JsonResult/String";
|
||||
|
|
@ -116,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_CustomFormatter_Conneg(string mediaType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/JsonResult/CustomFormatter";
|
||||
|
|
@ -142,7 +141,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_CustomFormatter_Conneg_Fails(string mediaType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/JsonResult/CustomFormatter";
|
||||
|
|
@ -164,7 +163,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonResult_CustomContentType()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/JsonResult/CustomContentType";
|
||||
|
|
|
|||
|
|
@ -7,14 +7,13 @@ using System.Net.Http.Headers;
|
|||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class LinkGenerationTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("BasicWebSite");
|
||||
private const string SiteName = nameof(BasicWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
|
||||
|
||||
// Some tests require comparing the actual response body against an expected response baseline
|
||||
|
|
@ -29,7 +28,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GeneratedLinksWithActionResults_AreRelativeLinks_WhenSetOnLocationHeader(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -48,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GeneratedLinks_AreNotPunyEncoded_WhenGeneratedOnViews()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ using System.Threading.Tasks;
|
|||
using LoggingWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Logging;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -19,14 +18,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class LoggingActionSelectionTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(LoggingWebSite));
|
||||
private readonly Action<IApplicationBuilder> _app = new LoggingWebSite.Startup().Configure;
|
||||
|
||||
private const string SiteName = nameof(LoggingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task Successful_ActionSelection_Logged()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var requestTraceId = Guid.NewGuid().ToString();
|
||||
|
||||
|
|
@ -61,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task Failed_ActionSelection_Logged()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var requestTraceId = Guid.NewGuid().ToString();
|
||||
|
||||
|
|
@ -95,7 +94,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
var logActivities = JsonConvert.DeserializeObject<List<ActivityContextDto>>(responseData);
|
||||
return logActivities.FilterByRequestTraceId(requestTraceId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ using LoggingWebSite.Controllers;
|
|||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
using Microsoft.AspNet.Mvc.Logging;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -19,8 +18,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class LoggingStartupTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(LoggingWebSite));
|
||||
private readonly Action<IApplicationBuilder> _app = new LoggingWebSite.Startup().Configure;
|
||||
private const string SiteName = nameof(LoggingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task AssemblyValues_LoggedAtStartup()
|
||||
|
|
@ -88,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
private async Task<IEnumerable<LogInfoDto>> GetLogsByDataTypeAsync<T>()
|
||||
{
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var response = await client.GetStringAsync("http://localhost/logs");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ModelBindingWebSite;
|
||||
using ModelBindingWebSite.Controllers;
|
||||
using ModelBindingWebSite.Models;
|
||||
|
|
@ -17,14 +16,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ModelBindingFromFormTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ModelBindingWebSite));
|
||||
private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure;
|
||||
private const string SiteName = nameof(ModelBindingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task FromForm_CustomModelPrefix_ForParameter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/FromFormAttribute_Company/CreateCompany";
|
||||
|
|
@ -52,7 +51,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromForm_CustomModelPrefix_ForCollectionParameter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/FromFormAttribute_Company/CreateCompanyFromEmployees";
|
||||
|
|
@ -78,7 +77,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromForm_CustomModelPrefix_ForProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/FromFormAttribute_Company/CreateCompany";
|
||||
|
|
@ -104,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromForm_CustomModelPrefix_ForCollectionProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/FromFormAttribute_Company/CreateDepartment";
|
||||
|
|
@ -131,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromForm_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/FromFormAttribute_Company/ValidateDepartment";
|
||||
|
|
|
|||
|
|
@ -6,15 +6,14 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class ModelBindingFromHeaderTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ModelBindingWebSite));
|
||||
private const string SiteName = nameof(ModelBindingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure;
|
||||
|
||||
// The action that this test hits will echo back the model-bound value
|
||||
|
|
@ -27,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expected = headerValue;
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter");
|
||||
|
|
@ -51,7 +50,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
var title = "How to make really really good soup.";
|
||||
var tags = new string[] { "Cooking", "Recipes", "Awesome" };
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName");
|
||||
|
|
@ -77,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var tags = new string[] { "Cooking", "Recipes", "Awesome" };
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName");
|
||||
|
|
@ -100,7 +99,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromHeader_NonExistingHeaderAddsValidationErrors_OnCollectionProperty_CustomName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToProperty/CustomName");
|
||||
|
|
@ -126,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expected = "1e331f25-0869-4c87-8a94-64e6e40cb5a0";
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter/CustomName");
|
||||
|
|
@ -154,7 +153,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expected = headerValue;
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringParameter");
|
||||
|
|
@ -182,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string headerValue)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -213,7 +212,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expected = headerValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToStringArrayParameter");
|
||||
|
|
@ -241,7 +240,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
var title = "How to make really really good soup.";
|
||||
var tags = new string[] { "Cooking", "Recipes", "Awesome" };
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToModel?author=Marvin");
|
||||
|
|
@ -269,7 +268,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromHeader_BindHeader_ToModel_NoValues_ValidationError()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Blog/BindToModel?author=Marvin");
|
||||
|
|
@ -299,7 +298,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromHeader_BindHeader_ToModel_NoValues_InitializedValue_ValidationError()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -331,7 +330,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromHeader_BindHeader_ToModel_NoValues_DefaultValue_NoValidationError()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
|
|||
|
|
@ -4,25 +4,24 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ModelBindingWebSite;
|
||||
using ModelBindingWebSite.Controllers;
|
||||
using ModelBindingWebSite.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using ModelBindingWebSite.Controllers;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class ModelBindingFromQueryTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ModelBindingWebSite));
|
||||
private const string SiteName = nameof(ModelBindingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task FromQuery_CustomModelPrefix_ForParameter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// [FromQuery(Name = "customPrefix")] is used to apply a prefix
|
||||
|
|
@ -44,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromQuery_CustomModelPrefix_ForCollectionParameter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url =
|
||||
|
|
@ -65,7 +64,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromQuery_CustomModelPrefix_ForProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// [FromQuery(Name = "EmployeeId")] is used to apply a prefix
|
||||
|
|
@ -88,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromQuery_CustomModelPrefix_ForCollectionProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url =
|
||||
|
|
@ -111,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromQuery_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url =
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ModelBindingWebSite;
|
||||
using ModelBindingWebSite.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -16,14 +15,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ModelBindingFromRouteTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ModelBindingWebSite));
|
||||
private const string SiteName = nameof(ModelBindingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task FromRoute_CustomModelPrefix_ForParameter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// [FromRoute(Name = "customPrefix")] is used to apply a prefix
|
||||
|
|
@ -43,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromRoute_CustomModelPrefix_ForProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// [FromRoute(Name = "EmployeeId")] is used to apply a prefix
|
||||
|
|
@ -64,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FromRoute_NonExistingValueAddsValidationErrors_OnProperty_UsingCustomModelPrefix()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// [FromRoute(Name = "TestEmployees")] is used to apply a prefix
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ModelBindingWebSite.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
|
@ -13,14 +12,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ModelBindingModelBinderAttributeTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ModelBindingWebSite));
|
||||
private const string SiteName = nameof(ModelBindingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ModelBinderAttribute_CustomModelPrefix()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// [ModelBinder(Name = "customPrefix")] is used to apply a prefix
|
||||
|
|
@ -42,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBinderAttribute_CustomModelPrefix_OnProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url =
|
||||
|
|
@ -65,7 +64,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBinderAttribute_WithPrefixOnParameter(string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// [ModelBinder(Name = "customPrefix")] is used to apply a prefix
|
||||
|
|
@ -90,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBinderAttribute_WithBinderOnParameter(string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url =
|
||||
|
|
@ -112,7 +111,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBinderAttribute_WithBinderOnEnum()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url =
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ using System.Reflection;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ModelBindingWebSite.Models;
|
||||
using ModelBindingWebSite.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -21,14 +20,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ModelBindingTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("ModelBindingWebSite");
|
||||
private const string SiteName = nameof(ModelBindingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new ModelBindingWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task TypeBasedExclusion_ForBodyAndNonBodyBoundModels()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Make sure the body object gets created with an invalid zip.
|
||||
|
|
@ -50,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelValidation_DoesNotValidate_AnAlreadyValidatedObject()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -70,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CompositeModelBinder_Restricts_ValueProviders(string actionName, string expectedValue)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Provide all three values, it should bind based on the attribute on the action method.
|
||||
|
|
@ -95,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModel_WithAPropertyFromBody()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// the name would be of customer.Department.Name
|
||||
|
|
@ -121,7 +120,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanModelBindServiceToAnArgument()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -135,7 +134,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task CanModelBindServiceToAProperty()
|
||||
{
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -150,7 +149,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task CanModelBindServiceToAProperty_OnBaseType()
|
||||
{
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -166,7 +165,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MultipleParametersMarkedWithFromBody_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -184,7 +183,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MultipleParameterAndPropertiesMarkedWithFromBody_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -202,7 +201,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MultipleParametersMarkedWith_FromFormAndFromBody_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -220,7 +219,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MultipleParameterAndPropertiesMarkedWith_FromFormAndFromBody_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -238,7 +237,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanBind_MultipleParameters_UsingFromForm()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post,
|
||||
|
|
@ -276,7 +275,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanBind_MultipleProperties_UsingFromForm()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post,
|
||||
|
|
@ -314,7 +313,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanBind_ComplexData_OnParameters_UsingFromAttributes()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Provide all three values, it should bind based on the attribute on the action method.
|
||||
|
|
@ -358,7 +357,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanBind_ComplexData_OnProperties_UsingFromAttributes()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Provide all three values, it should bind based on the attribute on the action method.
|
||||
|
|
@ -402,7 +401,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanBind_ComplexData_OnProperties_UsingFromAttributes_WithBody()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Provide all three values, it should bind based on the attribute on the action method.
|
||||
|
|
@ -442,7 +441,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NonExistingModelBinder_ForABinderMetadata_DoesNotRecurseInfinitely()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act & Assert
|
||||
|
|
@ -460,7 +459,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ParametersWithNoValueProviderMetadataUseTheAvailableValueProviders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -482,7 +481,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ParametersAreAlwaysCreated_IfValuesAreProvidedWithoutModelName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -504,7 +503,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ParametersAreAlwaysCreated_IfValueIsProvidedForModelName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -525,7 +524,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ParametersAreAlwaysCreated_IfNoValuesAreProvided()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -546,7 +545,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PropertiesAreBound_IfTheyAreProvidedByValueProviders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -568,7 +567,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PropertiesAreBound_IfTheyAreMarkedExplicitly()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -589,7 +588,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PropertiesAreBound_IfTheyArePocoMetadataMarkedTypes()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -614,7 +613,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PropertiesAreNotBound_ByDefault()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -636,7 +635,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanBind_ComplexData_FromRouteData(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -659,7 +658,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBindCancellationTokenParameteres()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -674,7 +673,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBindCancellationToken_ForProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -690,7 +689,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBindingBindsBase64StringsToByteArrays()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -705,7 +704,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBindingBindsEmptyStringsToByteArrays()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -720,7 +719,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBinding_LimitsErrorsToMaxErrorCount()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var queryString = string.Join("=&", Enumerable.Range(0, 10).Select(i => "field" + i));
|
||||
|
||||
|
|
@ -745,7 +744,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelBinding_ValidatesAllPropertiesInModel()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -763,7 +762,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_Filters_UsingDefaultPropertyFilterProvider_WithExpressions()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -786,7 +785,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_Filters_UsingPropertyFilterProvider_UsingServices()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -809,7 +808,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_Filters_UsingDefaultPropertyFilterProvider_WithPredicate()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -828,7 +827,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_BlacklistedAtEitherLevelIsNotBound()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -847,7 +846,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_IncludedAtBothLevelsIsBound()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -865,7 +864,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_AppliesAtBothParameterAndTypeLevelTogether_IncludingAtOneLevelIsNotBound()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -884,7 +883,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_BindsUsingParameterPrefix()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -900,7 +899,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_DoesNotUseTypePrefix()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -916,7 +915,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_FallsBackOnEmptyPrefixIfNoParameterPrefixIsProvided()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -932,7 +931,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindAttribute_DoesNotFallBackOnEmptyPrefixIfParameterPrefixIsProvided()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -949,7 +948,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModel_IncludeTopLevelProperty_IncludesAllSubProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -978,7 +977,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModel_ChainedPropertyExpression_Throws()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
Expression<Func<User, object>> expression = model => model.Address.Country;
|
||||
|
||||
|
|
@ -1000,7 +999,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModel_FailsToUpdateProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1019,7 +1018,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModel_IncludeExpression_WorksOnlyAtTopLevel()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1042,7 +1041,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModel_Validates_ForTopLevelNotIncludedProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1059,7 +1058,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModelExcludeSpecific_Properties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1082,7 +1081,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModelIncludeSpecific_Properties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1105,7 +1104,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModelIncludesAllProperties_ByDefault()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1128,7 +1127,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task UpdateVehicle_WithJson_ProducesModelStateErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new
|
||||
{
|
||||
|
|
@ -1164,7 +1163,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task UpdateVehicle_WithJson_DoesPropertyValidationPriorToValidationAtType()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new
|
||||
{
|
||||
|
|
@ -1198,7 +1197,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task UpdateVehicle_WithJson_BindsBodyAndServices()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var trackingId = Guid.NewGuid().ToString();
|
||||
var postedContent = new
|
||||
|
|
@ -1235,7 +1234,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task UpdateVehicle_WithXml_BindsBodyServicesAndHeaders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var trackingId = Guid.NewGuid().ToString();
|
||||
var postedContent = new VehicleViewModel
|
||||
|
|
@ -1275,7 +1274,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/UpdateDealerVehicle_PopulatesPropertyErrorsInViews.txt");
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var postedContent = new
|
||||
{
|
||||
|
|
@ -1306,7 +1305,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/UpdateDealerVehicle_PopulatesValidationSummary.txt");
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var postedContent = new
|
||||
{
|
||||
|
|
@ -1337,7 +1336,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/UpdateDealerVehicle_UpdateSuccessful.txt");
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var postedContent = new
|
||||
{
|
||||
|
|
@ -1366,7 +1365,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormFileModelBinder_CanBind_SingleFile()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FileUpload/UploadSingle";
|
||||
var formData = new MultipartFormDataContent("Upload----");
|
||||
|
|
@ -1387,7 +1386,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormFileModelBinder_CanBind_MultipleFiles()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FileUpload/UploadMultiple";
|
||||
var formData = new MultipartFormDataContent("Upload----");
|
||||
|
|
@ -1412,7 +1411,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormFileModelBinder_CanBind_MultipleListOfFiles()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FileUpload/UploadMultipleList";
|
||||
var formData = new MultipartFormDataContent("Upload----");
|
||||
|
|
@ -1447,7 +1446,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormFileModelBinder_CanBind_FileInsideModel()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FileUpload/UploadModelWithFile";
|
||||
var formData = new MultipartFormDataContent("Upload----");
|
||||
|
|
@ -1472,7 +1471,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModel_ReturnDerivedAndBaseProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1495,7 +1494,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/ModelBindingWebSite.Vehicle.Details.html");
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/vehicles/42";
|
||||
|
||||
|
|
@ -1515,7 +1514,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/ModelBindingWebSite.Vehicle.Edit.html");
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/vehicles/42/edit";
|
||||
|
||||
|
|
@ -1535,7 +1534,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var expectedContent = await GetType().GetTypeInfo().Assembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/ModelBindingWebSite.Vehicle.Edit.Invalid.html");
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/vehicles/42/edit";
|
||||
var contentDictionary = new Dictionary<string, string>
|
||||
|
|
@ -1573,7 +1572,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/Home/GetErrorMessage";
|
||||
|
||||
|
|
@ -1596,7 +1595,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task OverriddenMetadataProvider_CanChangeAdditionalValues()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/AdditionalValues";
|
||||
var expectedDictionary = new Dictionary<string, string>
|
||||
|
|
@ -1619,7 +1618,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task OverriddenMetadataProvider_CanUseAttributesToChangeAdditionalValues()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/GroupNames";
|
||||
var expectedDictionary = new Dictionary<string, string>
|
||||
|
|
@ -1646,7 +1645,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModelNonGeneric_IncludesAllProperties_CanBind()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1669,7 +1668,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormCollectionModelBinder_CanBind_FormValues()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FormCollection/ReturnValuesAsList";
|
||||
var nameValueCollection = new List<KeyValuePair<string, string>>
|
||||
|
|
@ -1693,7 +1692,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormCollectionModelBinder_CanBind_FormValuesWithDuplicateKeys()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FormCollection/ReturnValuesAsList";
|
||||
var nameValueCollection = new List<KeyValuePair<string, string>>
|
||||
|
|
@ -1718,7 +1717,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormCollectionModelBinder_CannotBind_NonFormValues()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FormCollection/ReturnCollectionCount";
|
||||
var data = new StringContent("Non form content");
|
||||
|
|
@ -1737,7 +1736,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task FormCollectionModelBinder_CanBind_FormWithFile()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost/FormCollection/ReturnFileContent";
|
||||
var expectedContent = "Test Content";
|
||||
|
|
@ -1757,7 +1756,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryUpdateModelNonGenericIncludesAllProperties_ByDefault()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1823,7 +1822,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
IEnumerable<string> expectedModelStateErrorMessages)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new StringContent(input, Encoding.UTF8, "text/json");
|
||||
|
||||
|
|
@ -1849,7 +1848,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindModelAsync_WithCollection()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -1875,7 +1874,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindModelAsync_WithCollection_SpecifyingIndex()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new[]
|
||||
{
|
||||
|
|
@ -1901,7 +1900,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindModelAsync_WithNestedCollection()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -1936,7 +1935,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindModelAsync_WithIncorrectlyFormattedNestedCollectionValue()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -1959,7 +1958,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindModelAsync_WithNestedCollectionContainingRecursiveRelation()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -1997,7 +1996,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindModelAsync_WithNestedCollectionContainingRecursiveRelation_WithMalformedValue()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -2024,7 +2023,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
bool expectedResult)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
|
|
@ -2046,7 +2045,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task BindModelAsync_CheckBoxesList_BindSuccessful()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var content = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.Net.Http;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -15,14 +14,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ModelMetadataAttributeTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ValidationWebSite));
|
||||
private const string SiteName = nameof(ValidationWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ModelMetaDataTypeAttribute_ValidBaseClass_EmptyResponseBody()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Name\": \"MVC\", \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
|
||||
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 21, \"ProductDetails\": {\"Detail1\": \"d1\"," +
|
||||
|
|
@ -43,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelMetaDataTypeAttribute_InvalidPropertiesAndSubPropertiesOnBaseClass_ReturnsErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Price\": 2, \"ProductDetails\": {\"Detail1\": \"d1\"}}";
|
||||
var content = new StringContent(input, Encoding.UTF8, "application/json");
|
||||
|
|
@ -69,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelMetaDataTypeAttribute_InvalidComplexTypePropertyOnBaseClass_ReturnsErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Contact\":\"4255678765\", \"Category\":\"Technology\"," +
|
||||
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 21 }";
|
||||
|
|
@ -91,7 +90,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelMetaDataTypeAttribute_InvalidClassAttributeOnBaseClass_ReturnsErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
|
||||
"\"CompanyName\":\"Microsoft\", \"Country\":\"UK\",\"Price\": 21, \"ProductDetails\": {\"Detail1\": \"d1\"," +
|
||||
|
|
@ -115,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelMetaDataTypeAttribute_ValidDerivedClass_EmptyResponseBody()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Name\": \"MVC\", \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
|
||||
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\", \"Version\":\"2\"," +
|
||||
|
|
@ -136,7 +135,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelMetaDataTypeAttribute_InvalidPropertiesOnDerivedClass_ReturnsErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Name\": \"MVC\", \"Contact\":\"425-895-9019\", \"Category\":\"Technology\"," +
|
||||
"\"CompanyName\":\"Microsoft\", \"Country\":\"USA\",\"Price\": 2}";
|
||||
|
|
@ -159,7 +158,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelMetaDataTypeAttribute_InvalidClassAttributeOnBaseClassProduct_ReturnsErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Contact\":\"4258959019\", \"Category\":\"Technology\"," +
|
||||
"\"CompanyName\":\"Microsoft\", \"Country\":\"UK\",\"Version\":\"2\"," +
|
||||
|
|
@ -177,6 +176,5 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
Assert.Equal(1, json.Count);
|
||||
Assert.Equal("Product must be made in the USA if it is not named.", json["software"]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -10,16 +10,17 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class MvcSampleTests
|
||||
{
|
||||
private const string SiteName = nameof(MvcSample) + "." + nameof(MvcSample.Web);
|
||||
|
||||
// Path relative to Mvc\\test\Microsoft.AspNet.Mvc.FunctionalTests
|
||||
private readonly IServiceProvider _services =
|
||||
TestHelper.CreateServices("MvcSample.Web", Path.Combine("..", "..", "samples"));
|
||||
private readonly static string SamplesFolder = Path.Combine("..", "..", "samples");
|
||||
|
||||
private readonly Action<IApplicationBuilder> _app = new MvcSample.Web.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -37,19 +38,16 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[InlineData("/Home/ValidationSummary")] // Home/ValidationSummary.cshtml
|
||||
public async Task Home_Pages_ReturnSuccess(string path)
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost" + path);
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost" + path);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -67,84 +65,72 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[InlineData("Name=SamplePerson", "false")]
|
||||
public async Task FormUrlEncoded_ReturnsAppropriateResults(string input, string expectedOutput)
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/FormUrlEncoded/IsValidPerson");
|
||||
request.Content = new StringContent(input, Encoding.UTF8, "application/x-www-form-urlencoded");
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/FormUrlEncoded/IsValidPerson");
|
||||
request.Content = new StringContent(input, Encoding.UTF8, "application/x-www-form-urlencoded");
|
||||
|
||||
// Act
|
||||
var response = await client.SendAsync(request);
|
||||
// Act
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedOutput, await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
// Assert
|
||||
Assert.Equal(expectedOutput, await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FormUrlEncoded_Index_ReturnSuccess()
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/FormUrlEncoded");
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/FormUrlEncoded");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Home_NotFoundAction_Returns404()
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Home/NotFound");
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Home/NotFound");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Home_CreateUser_ReturnsXmlBasedOnAcceptHeader()
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/ReturnUser");
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8"));
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/ReturnUser");
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8"));
|
||||
|
||||
// Act
|
||||
var response = await client.SendAsync(request);
|
||||
// Act
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
XmlAssert.Equal("<User xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=" +
|
||||
"\"http://schemas.datacontract.org/2004/07/MvcSample.Web.Models\"><About>I like playing Football" +
|
||||
"</About><Address>My address</Address><Age>13</Age><Alive>true</Alive><Dependent><About i:nil=\"true\" />" +
|
||||
"<Address>Dependents address</Address><Age>0</Age><Alive>false</Alive><Dependent i:nil=\"true\" />" +
|
||||
"<GPA>0</GPA><Log i:nil=\"true\" /><Name>Dependents name</Name><Password i:nil=\"true\" />" +
|
||||
"<Profession i:nil=\"true\" /></Dependent><GPA>13.37</GPA><Log i:nil=\"true\" />" +
|
||||
"<Name>My name</Name><Password>Secure string</Password><Profession>Software Engineer</Profession></User>",
|
||||
await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
XmlAssert.Equal("<User xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=" +
|
||||
"\"http://schemas.datacontract.org/2004/07/MvcSample.Web.Models\"><About>I like playing Football" +
|
||||
"</About><Address>My address</Address><Age>13</Age><Alive>true</Alive><Dependent><About i:nil=\"true\" />" +
|
||||
"<Address>Dependents address</Address><Age>0</Age><Alive>false</Alive><Dependent i:nil=\"true\" />" +
|
||||
"<GPA>0</GPA><Log i:nil=\"true\" /><Name>Dependents name</Name><Password i:nil=\"true\" />" +
|
||||
"<Profession i:nil=\"true\" /></Dependent><GPA>13.37</GPA><Log i:nil=\"true\" />" +
|
||||
"<Name>My name</Name><Password>Secure string</Password><Profession>Software Engineer</Profession></User>",
|
||||
await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -153,38 +139,32 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[InlineData("http://localhost/Filters/NotGrantedClaim", HttpStatusCode.Unauthorized)]
|
||||
public async Task FiltersController_Tests(string url, HttpStatusCode statusCode)
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync(url);
|
||||
// Act
|
||||
var response = await client.GetAsync(url);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(statusCode, response.StatusCode);
|
||||
}
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(statusCode, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FiltersController_Crash_ThrowsException()
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(_app, SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Filters/Crash?message=HelloWorld");
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/Filters/Crash?message=HelloWorld");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal("Boom HelloWorld", await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal("Boom HelloWorld", await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,14 +3,13 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class MvcStartupTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("AddServicesWebSite");
|
||||
private const string SiteName = nameof(AddServicesWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new AddServicesWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
|
|
@ -22,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
|
||||
|
||||
// Act & Assert
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => TestServer.Create(_provider, _app));
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => TestHelper.CreateServer(_app, SiteName));
|
||||
Assert.Equal(expectedMessage, ex.Message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,7 @@ using System.Net.Http.Headers;
|
|||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Internal;
|
||||
using MvcTagHelpersWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -22,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class MvcTagHelpersTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("MvcTagHelpersWebSite");
|
||||
private const string SiteName = nameof(MvcTagHelpersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
private static readonly Assembly _resourcesAssembly = typeof(MvcTagHelpersTest).GetTypeInfo().Assembly;
|
||||
|
||||
|
|
@ -51,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task MvcTagHelpers_GeneratesExpectedResults(string action, string antiForgeryPath)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||
|
||||
|
|
@ -82,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ValidationTagHelpers_GeneratesExpectedSpansAndDivs()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/MvcTagHelpersWebSite.MvcTagHelper_Customer.Index.html");
|
||||
|
|
@ -116,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var assertFile =
|
||||
"compiler/resources/CacheTagHelper_CanCachePortionsOfViewsPartialViewsAndViewComponents.Assert";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost");
|
||||
client.DefaultRequestHeaders.Add("Locale", "North");
|
||||
|
|
@ -165,7 +161,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CacheTagHelper_ExpiresContent_BasedOnExpiresParameter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost");
|
||||
|
||||
|
|
@ -189,7 +185,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CacheTagHelper_UsesVaryByCookie_ToVaryContent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost");
|
||||
|
||||
|
|
@ -221,7 +217,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CacheTagHelper_VariesByRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost");
|
||||
|
||||
|
|
@ -277,7 +273,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CacheTagHelper_VariesByUserId()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost");
|
||||
|
||||
|
|
@ -304,7 +300,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CacheTagHelper_BubblesExpirationOfNestedTagHelpers()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost");
|
||||
|
||||
|
|
@ -349,8 +345,7 @@ Products: Laptops (3)";
|
|||
// Arrange
|
||||
var newServices = new ServiceCollection();
|
||||
newServices.ConfigureTagHelpers().ConfigureForm(options => options.GenerateAntiForgeryToken = optionsAntiForgery);
|
||||
var serviceProvider = TestHelper.CreateServices("MvcTagHelpersWebSite", newServices);
|
||||
var server = TestServer.Create(serviceProvider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.Add(newServices));
|
||||
var client = server.CreateClient();
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||
|
||||
|
|
@ -366,10 +361,10 @@ Products: Laptops (3)";
|
|||
// The host is not important as everything runs in memory and tests are isolated from each other.
|
||||
var response = await client.GetAsync("http://localhost/MvcTagHelper_Home/Form");
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
var forgeryTokens = AntiForgeryTestHelper.RetrieveAntiForgeryTokens(responseContent);
|
||||
expectedContent = string.Format(expectedContent, forgeryTokens.ToArray());
|
||||
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
|
||||
|
|
|
|||
|
|
@ -7,14 +7,13 @@ using System.Net.Http.Headers;
|
|||
using System.Threading.Tasks;
|
||||
using ContentNegotiationWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class OutputFormatterTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(ContentNegotiationWebSite));
|
||||
private const string SiteName = nameof(ContentNegotiationWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -25,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task StringOutputFormatter_ForStringValues_GetsSelectedReturnsTextPlainContentType(string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("text/plain;charset=utf-8");
|
||||
var expectedBody = actionName;
|
||||
|
|
@ -45,7 +44,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task JsonOutputFormatter_ForNonStringValue_GetsSelected(string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8");
|
||||
|
||||
|
|
@ -62,7 +61,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoContentFormatter_ForVoidAndTaskReturnType_GetsSelectedAndWritesResponse(string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -84,7 +83,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task NoContentFormatter_ForNullValue_ByDefault_GetsSelectedAndWritesResponse(string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -107,7 +106,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
NoContentFormatter_ForNullValue_AndTreatNullAsNoContentFlagSetToFalse_DoesNotGetSelected(string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Reflection;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using PrecompilationWebSite;
|
||||
|
|
@ -19,15 +18,20 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class PrecompilationTest
|
||||
{
|
||||
private const string SiteName = nameof(PrecompilationWebSite);
|
||||
private static readonly TimeSpan _cacheDelayInterval = TimeSpan.FromSeconds(1);
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(PrecompilationWebSite));
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task PrecompiledView_RendersCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
var applicationEnvironment = _services.GetRequiredService<IApplicationEnvironment>();
|
||||
IServiceCollection serviceCollection = null;
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => serviceCollection = services);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
var applicationEnvironment = serviceProvider.GetRequiredService<IApplicationEnvironment>();
|
||||
|
||||
var viewsDirectory = Path.Combine(applicationEnvironment.ApplicationBasePath, "Views", "Home");
|
||||
var layoutContent = File.ReadAllText(Path.Combine(viewsDirectory, "Layout.cshtml"));
|
||||
|
|
@ -35,9 +39,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
var viewstartContent = File.ReadAllText(Path.Combine(viewsDirectory, "_ViewStart.cshtml"));
|
||||
var globalContent = File.ReadAllText(Path.Combine(viewsDirectory, "_GlobalImport.cshtml"));
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// We will render a view that writes the fully qualified name of the Assembly containing the type of
|
||||
// the view. If the view is precompiled, this assembly will be PrecompilationWebsite.
|
||||
var assemblyNamePrefix = GetAssemblyNamePrefix();
|
||||
|
|
@ -169,7 +170,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
@"Value set inside DNXCORE50 " + assemblyNamePrefix;
|
||||
#endif
|
||||
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -185,10 +186,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = GetAssemblyNamePrefix();
|
||||
var server = TestServer.Create(_services, _app);
|
||||
IServiceCollection serviceCollection = null;
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => serviceCollection = services);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var applicationEnvironment = _services.GetRequiredService<IApplicationEnvironment>();
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
var applicationEnvironment = serviceProvider.GetRequiredService<IApplicationEnvironment>();
|
||||
|
||||
var viewsDirectory = Path.Combine(applicationEnvironment.ApplicationBasePath,
|
||||
"Views",
|
||||
|
|
@ -226,7 +229,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
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-min=""10"" id=""Age"" name=""Age"" value="""" /><a href="""">Back to List</a></root>";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -244,7 +247,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Arrange
|
||||
var assemblyNamePrefix = GetAssemblyNamePrefix();
|
||||
var expected = @"<root>root-content</root>";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -297,6 +300,5 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
public string Index { get; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using RazorCompilerCacheWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -13,14 +12,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class RazorCompilerCacheTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(RazorCompilerCacheWebSite));
|
||||
private const string SiteName = nameof(RazorCompilerCacheWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task CompilerCache_IsNotInitializedUntilFirstViewRequest()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.BaseAddress = new Uri("http://localhost");
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using RazorEmbeddedViewsWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -12,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class RazorEmbeddedViewsTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(RazorEmbeddedViewsWebSite));
|
||||
private const string SiteName = nameof(RazorEmbeddedViewsWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
|
|
@ -20,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expectedMessage = "Hello test-user, this is /RazorEmbeddedViews_Home";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -35,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expectedMessage = "Hello admin-user, this is /Restricted/RazorEmbeddedViews_Admin/Login";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var target = "http://localhost/Restricted/RazorEmbeddedViews_Admin/Login?AdminUser=admin-user";
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using RazorPageExecutionInstrumentationWebSite;
|
||||
using Xunit;
|
||||
|
|
@ -14,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class RazorPageExecutionInstrumentationTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(RazorPageExecutionInstrumentationWebSite));
|
||||
private const string SiteName = nameof(RazorPageExecutionInstrumentationWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
public static IEnumerable<object[]> InstrumentationData
|
||||
|
|
@ -94,14 +93,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
[Theory]
|
||||
[MemberData(nameof(InstrumentationData))]
|
||||
public async Task ViewsAreServedWithoutInstrumentationByDefault(string actionName,
|
||||
string expected,
|
||||
IEnumerable<Tuple<int, int, bool>> expectedLineMappings)
|
||||
public async Task ViewsAreServedWithoutInstrumentationByDefault(
|
||||
string actionName,
|
||||
string expected,
|
||||
IEnumerable<Tuple<int, int, bool>> expectedLineMappings)
|
||||
{
|
||||
// Arrange
|
||||
var context = new TestPageExecutionContext();
|
||||
var services = GetServiceProvider(context);
|
||||
var server = TestServer.Create(services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context));
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -114,14 +113,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
[Theory]
|
||||
[MemberData(nameof(InstrumentationData))]
|
||||
public async Task ViewsAreInstrumentedWhenPageExecutionListenerFeatureIsEnabled(string actionName,
|
||||
string expected,
|
||||
IEnumerable<Tuple<int, int, bool>> expectedLineMappings)
|
||||
public async Task ViewsAreInstrumentedWhenPageExecutionListenerFeatureIsEnabled(
|
||||
string actionName,
|
||||
string expected,
|
||||
IEnumerable<Tuple<int, int, bool>> expectedLineMappings)
|
||||
{
|
||||
// Arrange
|
||||
var context = new TestPageExecutionContext();
|
||||
var services = GetServiceProvider(context);
|
||||
var server = TestServer.Create(services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context));
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("ENABLE-RAZOR-INSTRUMENTATION", "true");
|
||||
|
||||
|
|
@ -135,14 +134,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
[Theory]
|
||||
[MemberData(nameof(InstrumentationData))]
|
||||
public async Task ViewsCanSwitchFromRegularToInstrumented(string actionName,
|
||||
string expected,
|
||||
IEnumerable<Tuple<int, int, bool>> expectedLineMappings)
|
||||
public async Task ViewsCanSwitchFromRegularToInstrumented(
|
||||
string actionName,
|
||||
string expected,
|
||||
IEnumerable<Tuple<int, int, bool>> expectedLineMappings)
|
||||
{
|
||||
// Arrange - 1
|
||||
var context = new TestPageExecutionContext();
|
||||
var services = GetServiceProvider(context);
|
||||
var server = TestServer.Create(services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context));
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act - 1
|
||||
|
|
@ -184,8 +183,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
Tuple.Create(35, 8, true),
|
||||
};
|
||||
var context = new TestPageExecutionContext();
|
||||
var services = GetServiceProvider(context);
|
||||
var server = TestServer.Create(services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services => services.AddInstance(context));
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act - 1
|
||||
|
|
@ -203,12 +201,5 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Assert - 2
|
||||
Assert.Equal(expectedLineMappings, context.Values);
|
||||
}
|
||||
|
||||
private IServiceProvider GetServiceProvider(TestPageExecutionContext pageExecutionContext)
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddInstance(pageExecutionContext);
|
||||
return TestHelper.CreateServices(nameof(RazorPageExecutionInstrumentationWebSite), services);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using RazorWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -13,7 +12,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public class RazorViewLocationSpecificationTest
|
||||
{
|
||||
private const string BaseUrl = "http://localhost/ViewNameSpecification_Home/";
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("RazorWebSite");
|
||||
private const string SiteName = nameof(RazorWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -27,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
@"<layout>
|
||||
_ViewStart that specifies partial Layout
|
||||
</layout>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -48,7 +47,7 @@ _ViewStart that specifies partial Layout
|
|||
@"<non-shared>
|
||||
Layout specified in page
|
||||
</non-shared>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -67,7 +66,7 @@ Layout specified in page
|
|||
@"<non-shared>
|
||||
Page With Non Partial Layout
|
||||
</non-shared>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -89,7 +88,7 @@ Page With Non Partial Layout
|
|||
Non Shared Partial
|
||||
|
||||
</layout>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -8,16 +8,15 @@ using System.Net.Http;
|
|||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class RemoteAttributeValidationTest
|
||||
{
|
||||
private const string SiteName = nameof(ValidationWebSite);
|
||||
private static readonly Assembly _resourcesAssembly =
|
||||
typeof(RemoteAttributeValidationTest).GetTypeInfo().Assembly;
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(ValidationWebSite));
|
||||
private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -26,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RemoteAttribute_LeadsToExpectedValidationAttributes(string areaName, string pathSegment)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/ValidationWebSite." + areaName + ".RemoteAttribute_Home.Create.html");
|
||||
|
|
@ -53,7 +52,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string expectedContent)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost" + pathSegment +
|
||||
"/RemoteAttribute_Verify/IsIdAvailable?UserId1=Joe1&UserId2=Joe2&UserId3=Joe3&UserId4=Joe4";
|
||||
|
|
@ -77,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string expectedContent)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url = "http://localhost" + pathSegment + "/RemoteAttribute_Verify/IsIdAvailable";
|
||||
var contentDictionary = new Dictionary<string, string>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
|
|
@ -15,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// PER-REQUEST and does not linger around to impact the next request.
|
||||
public class RequestServicesTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(RequestServicesWebSite));
|
||||
private const string SiteName = nameof(RequestServicesWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new RequestServicesWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -28,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RequestServices(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act & Assert
|
||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RequestServices_TagHelper()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/Other/FromTagHelper";
|
||||
|
|
@ -74,7 +73,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RequestServices_ActionConstraint()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/Other/FromActionConstraint";
|
||||
|
|
|
|||
|
|
@ -8,14 +8,13 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class RespectBrowserAcceptHeaderTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(FormatterWebSite));
|
||||
private const string SiteName = nameof(FormatterWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -24,10 +23,10 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AllMediaRangeAcceptHeader_FirstFormatterInListWritesResponse(string acceptHeader)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("Accept", acceptHeader);
|
||||
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("http://localhost/RespectBrowserAcceptHeader/EmployeeInfo");
|
||||
|
||||
|
|
@ -46,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AllMediaRangeAcceptHeader_ProducesAttributeIsHonored(string acceptHeader)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("Accept", acceptHeader);
|
||||
var expectedResponseData = "<RespectBrowserAcceptHeaderController.Employee xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
|
|
@ -71,13 +70,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AllMediaRangeAcceptHeader_WithContentTypeHeader_ContentTypeIsHonored(string acceptHeader)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Add("Accept", acceptHeader);
|
||||
var requestData = "<RespectBrowserAcceptHeaderController.Employee xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
" xmlns=\"http://schemas.datacontract.org/2004/07/FormatterWebSite.Controllers\"><Id>35</Id><Name>Jimmy" +
|
||||
"</Name></RespectBrowserAcceptHeaderController.Employee>";
|
||||
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsync("http://localhost/RespectBrowserAcceptHeader/CreateEmployee",
|
||||
new StringContent(requestData, Encoding.UTF8, "application/xml"));
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ResponseCacheWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -13,14 +12,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ResponseCacheTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("ResponseCacheWebSite");
|
||||
private const string SiteName = nameof(ResponseCacheWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ResponseCache_SetsAllHeaders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResponseCache_SetsDifferentCacheControlHeaders(string url, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -64,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task SetsHeadersForAllActionsOfClass()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -87,7 +86,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task HeadersSetInActionOverridesTheOnesInClass()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -102,7 +101,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task HeadersToNotCacheAParticularAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -117,7 +116,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ClassLevelHeadersAreUnsetByActionLevelHeaders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -137,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task SetsCacheControlPublicByDefault()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -152,7 +151,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ThrowsWhenDurationIsNotSet()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act & Assert
|
||||
|
|
@ -168,7 +167,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResponseCache_SetsAllHeaders_FromCacheProfile()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -183,7 +182,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResponseCache_SetsAllHeaders_ChosesTheRightProfile()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -198,7 +197,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResponseCache_SetsNoCacheHeaders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -215,7 +214,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResponseCache_AddsHeaders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -232,7 +231,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResponseCache_ModifiesHeaders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -247,7 +246,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ResponseCacheAttribute_OnAction_OverridesTheValuesOnClass()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ModelBindingWebSite;
|
||||
using ModelBindingWebSite.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -24,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
/// </summary>
|
||||
public class RoundTripTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("ModelBindingWebSite");
|
||||
private const string SiteName = nameof(ModelBindingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
// Uses the expression p => p.Name
|
||||
|
|
@ -33,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = "test-name";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -55,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = 40;
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -77,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = 12;
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -98,7 +97,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RoundTrippedValues_GetsModelBound_ForStringIndexedProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -115,7 +114,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var expected = "test-nested-name";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using Microsoft.AspNet.Builder;
|
|||
using Microsoft.AspNet.Mvc.Routing;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Routing.Template;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -17,14 +16,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class RouteDataTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(BasicWebSite));
|
||||
private const string SiteName = nameof(BasicWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new BasicWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task RouteData_Routers_ConventionalRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RouteData_Routers_AttributeRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -79,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RouteData_DataTokens_FilterCanSetDataTokens()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var response = await client.GetAsync("http://localhost/Routing/DataTokens");
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ using System;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class RoutingLowercaseUrlTest
|
||||
{
|
||||
private const string SiteName = nameof(LowercaseUrlsWebSite);
|
||||
|
||||
// This website sets the generation of lowercase URLs to true
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("LowercaseUrlsWebSite");
|
||||
private readonly Action<IApplicationBuilder> _app = new LowercaseUrlsWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task GenerateLowerCaseUrlsTests(string path, string expectedUrl)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -17,14 +16,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class RoutingTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("RoutingWebSite");
|
||||
private const string SiteName = nameof(RoutingWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new RoutingWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ConventionRoutedController_ActionIsReachable()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -52,7 +51,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionRoutedController_ActionIsReachable_WithDefaults()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -80,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionRoutedController_NonActionIsNotReachable()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -94,7 +93,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionRoutedController_InArea_ActionIsReachable()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -123,7 +122,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionRoutedController_InArea_ActionBlockedByHttpMethod()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -137,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_IsReachable()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -168,7 +167,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_MultipleRouteAttributes_WorksWithNameAndOrder(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -197,7 +196,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var url = "http://localhost/api/v2/Maps";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -225,7 +224,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var url = "http://localhost/api/v1/Maps";
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -245,7 +244,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string method)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -274,7 +273,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_MultipleHttpAttributesAndTokenReplacement(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedUrl = new Uri(url).AbsolutePath;
|
||||
|
||||
|
|
@ -308,7 +307,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string method)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedUrl = new Uri(url).AbsolutePath;
|
||||
|
||||
|
|
@ -324,7 +323,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_IsNotReachableWithTraditionalRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -340,7 +339,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_TriedBeforeConventionRouting()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -361,7 +360,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_ControllerLevelRoute_WithActionParameter_IsReachable()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -395,7 +394,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_ControllerLevelRoute_IsReachable()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -424,7 +423,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_RouteAttributeOnAction_IsReachable(string method)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var message = new HttpRequestMessage(new HttpMethod(method), "http://localhost/Store/Shop/Orders");
|
||||
|
||||
|
|
@ -451,7 +450,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_RouteAttributeOnActionAndController_IsReachable(string method)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var message = new HttpRequestMessage(new HttpMethod(method), "http://localhost/api/Employee/5/Salary");
|
||||
|
||||
|
|
@ -473,7 +472,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_RouteAttributeOnActionAndHttpGetOnDifferentAction_ReachesHttpGetAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var message = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Store/Shop/Orders");
|
||||
|
||||
|
|
@ -498,7 +497,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_ControllerLevelRoute_WithAcceptVerbs_IsReachable(string verb)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -522,7 +521,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_ControllerLevelRoute_WithAcceptVerbsAndRouteTemplate_IsReachable(string verb)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -548,7 +547,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_AcceptVerbsAndRouteTemplate_IsReachable(string verb, string path)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedUrl = "/Bank";
|
||||
|
||||
|
|
@ -571,7 +570,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_WithCustomHttpAttributes_IsReachable()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -597,7 +596,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_ControllerLevelRoute_CombinedWithActionRoute_IsReachable(string verb, string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -623,7 +622,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_ActionLevelRouteWithTildeSlash_OverridesControllerLevelRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -648,7 +647,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_OverrideActionOverridesOrderOnController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -673,7 +672,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_OrderOnActionOverridesOrderOnController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -694,7 +693,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkGeneration_OverrideActionOverridesOrderOnController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -709,7 +708,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkGeneration_OrderOnActionOverridesOrderOnController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -724,7 +723,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkToSelf()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -747,7 +746,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkWithAmbientController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -770,7 +769,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkToAttributeRoutedController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -794,7 +793,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkToConventionalController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -819,7 +818,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkWithName_WithNameInheritedFromControllerRoute(string method, string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -843,7 +842,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkWithName_WithNameOverrridenFromController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -866,7 +865,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_Link_WithNonEmptyActionRouteTemplateAndNoActionRouteName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = LinkFrom("http://localhost")
|
||||
|
|
@ -892,7 +891,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkWithName_WithNonEmptyActionRouteTemplateAndActionRouteName()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -919,7 +918,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_ThowsIfConventionalRouteWithTheSameName(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expectedMessage = "The supplied route name 'DuplicateRoute' is ambiguous and matched more than one route.";
|
||||
|
|
@ -936,7 +935,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionalRoutedAction_LinkToArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -960,7 +959,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionalRoutedAction_InArea_ImplicitLinkToArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -983,7 +982,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionalRoutedAction_InArea_ExplicitLeaveArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1006,7 +1005,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionalRoutedAction_InArea_ImplicitLeaveArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1029,7 +1028,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_LinkToArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1053,7 +1052,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_InArea_ImplicitLinkToArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1076,7 +1075,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_InArea_ExplicitLeaveArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1100,7 +1099,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_InArea_ImplicitLeaveArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1124,7 +1123,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_InArea_LinkToConventionalRoutedActionInArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1149,7 +1148,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionalRoutedAction_InArea_LinkToAttributeRoutedActionInArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1174,7 +1173,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ConventionalRoutedAction_InArea_LinkToAnotherArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1199,7 +1198,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_InArea_LinkToAnotherArea()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1224,7 +1223,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ControllerWithCatchAll_CanReachSpecificCountry()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1254,7 +1253,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ControllerWithCatchAll_CannotReachWithoutCountry()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1268,7 +1267,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ControllerWithCatchAll_GenerateLinkForSpecificCountry()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1288,7 +1287,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ControllerWithCatchAll_GenerateLinkForFallback()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1308,7 +1307,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ControllerWithCatchAll_GenerateLink_FailsWithoutCountry()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -1333,7 +1332,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRouting_MixedAcceptVerbsAndRoute_Reachable(string path, string verb, string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(verb), "http://localhost" + path);
|
||||
|
|
@ -1360,7 +1359,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRouting_MixedAcceptVerbsAndRoute_Unreachable(string path, string verb)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(verb), "http://localhost" + path);
|
||||
|
|
|
|||
|
|
@ -9,14 +9,13 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class SerializableErrorTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(XmlFormattersWebSite));
|
||||
private const string SiteName = nameof(XmlFormattersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -27,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ModelStateErrors_AreSerialized(string acceptHeader)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptHeader));
|
||||
var expectedXml = "<Error><key1>key1-error</key1><key2>The input was not valid.</key2></Error>";
|
||||
|
|
@ -52,7 +51,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task PostedSerializableError_IsBound(string acceptHeader)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptHeader));
|
||||
var expectedXml = "<Error><key1>key1-error</key1><key2>The input was not valid.</key2></Error>";
|
||||
|
|
@ -76,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task IsReturnedInExpectedFormat(string acceptHeader)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<Employee xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite.Models\">" +
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@ using System;
|
|||
using System.Threading.Tasks;
|
||||
using FormatterWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class StreamOutputFormatterTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(FormatterWebSite));
|
||||
private const string SiteName = nameof(FormatterWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -24,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task StreamOutputFormatter_ReturnsAppropriateContentAndContentType(string actionName, string contentType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.IO;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -15,6 +14,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class TagHelperSampleTest
|
||||
{
|
||||
private const string SiteName = nameof(TagHelperSample) + "." + nameof(TagHelperSample.Web);
|
||||
|
||||
// Path relative to Mvc\\test\Microsoft.AspNet.Mvc.FunctionalTests
|
||||
private readonly static string SamplesFolder = Path.Combine("..", "..", "samples");
|
||||
|
||||
private static readonly List<string> Paths = new List<string>
|
||||
{
|
||||
string.Empty,
|
||||
|
|
@ -33,33 +37,27 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
};
|
||||
|
||||
private readonly ILoggerFactory _loggerFactory = new TestLoggerFactory();
|
||||
// Path relative to Mvc\\test\Microsoft.AspNet.Mvc.FunctionalTests
|
||||
private readonly IServiceProvider _services =
|
||||
TestHelper.CreateServices("TagHelperSample.Web", Path.Combine("..", "..", "samples"));
|
||||
private readonly Action<IApplicationBuilder, ILoggerFactory> _app = new TagHelperSample.Web.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task Home_Pages_ReturnSuccess()
|
||||
{
|
||||
using (TestHelper.ReplaceCallContextServiceLocationService(_services))
|
||||
// Arrange
|
||||
var server = TestHelper.CreateServer(app => _app(app, _loggerFactory), SiteName, SamplesFolder);
|
||||
var client = server.CreateClient();
|
||||
|
||||
for (var index = 0; index < Paths.Count; index++)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, app => _app(app, _loggerFactory));
|
||||
var client = server.CreateClient();
|
||||
// Act
|
||||
var path = Paths[index];
|
||||
var response = await client.GetAsync("http://localhost" + path);
|
||||
|
||||
for (var index = 0; index < Paths.Count; index++)
|
||||
{
|
||||
// Act
|
||||
var path = Paths[index];
|
||||
var response = await client.GetAsync("http://localhost" + path);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class TestLoggerFactory : ILoggerFactory
|
||||
{
|
||||
public LogLevel MinimumLevel { get; set; }
|
||||
|
|
@ -68,36 +66,34 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ILogger CreateLogger(string name)
|
||||
{
|
||||
return new TestLogger();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class TestLogger : ILogger
|
||||
{
|
||||
public bool IsEnabled(LogLevel level)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public IDisposable BeginScope(object scope)
|
||||
{
|
||||
return new TestDisposable();
|
||||
}
|
||||
|
||||
|
||||
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class TestDisposable : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,13 @@ using System.Reflection;
|
|||
using System.Threading.Tasks;
|
||||
using BasicWebSite;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class TagHelpersTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("TagHelpersWebSite");
|
||||
private const string SiteName = nameof(TagHelpersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
// Some tests require comparing the actual response body against an expected response baseline
|
||||
|
|
@ -33,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanRenderViewsWithTagHelpers(string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||
|
||||
|
|
@ -88,7 +87,7 @@ page:<root/>
|
|||
public async Task TagHelpersAreInheritedFromViewStartPages(string action, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -102,7 +101,7 @@ page:<root/>
|
|||
public async Task ViewsWithModelMetadataAttributes_CanRenderForm()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/TagHelpersWebSite.Employee.Create.html");
|
||||
|
|
@ -120,7 +119,7 @@ page:<root/>
|
|||
public async Task ViewsWithModelMetadataAttributes_CanRenderPostedValue()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/TagHelpersWebSite.Employee.Details.AfterCreate.html");
|
||||
|
|
@ -148,7 +147,7 @@ page:<root/>
|
|||
public async Task ViewsWithModelMetadataAttributes_CanHandleInvalidData()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
|
||||
"compiler/resources/TagHelpersWebSite.Employee.Create.Invalid.html");
|
||||
|
|
|
|||
|
|
@ -7,25 +7,24 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class TempDataTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("TempDataWebSite");
|
||||
private const string SiteName = nameof(TempDataWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new TempDataWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ViewRendersTempData()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var nameValueCollection = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string,string>("value", "Foo"),
|
||||
new KeyValuePair<string, string>("value", "Foo"),
|
||||
};
|
||||
var content = new FormUrlEncodedContent(nameValueCollection);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Limits MVC to use a single Assembly for controller discovery.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is a generic type because it needs to instantiated by a service provider to replace
|
||||
/// a built-in MVC service.
|
||||
/// </remarks>
|
||||
public class TestAssemblyProvider<T> : IAssemblyProvider
|
||||
{
|
||||
public TestAssemblyProvider()
|
||||
{
|
||||
CandidateAssemblies = new Assembly[] { typeof(T).GetTypeInfo().Assembly };
|
||||
}
|
||||
|
||||
public IEnumerable<Assembly> CandidateAssemblies { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class TestConfigurationProvider : ITestConfigurationProvider
|
||||
{
|
||||
public TestConfigurationProvider()
|
||||
{
|
||||
Configuration = new Configuration();
|
||||
Configuration.Add(new MemoryConfigurationSource());
|
||||
}
|
||||
|
||||
public Configuration Configuration { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,13 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.ServiceLookup;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Microsoft.Framework.Runtime.Infrastructure;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
|
|
@ -20,128 +17,106 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
// Path from Mvc\\test\\Microsoft.AspNet.Mvc.FunctionalTests
|
||||
private static readonly string WebsitesDirectoryPath = Path.Combine("..", "WebSites");
|
||||
|
||||
public static IServiceProvider CreateServices(string applicationWebSiteName, IServiceCollection newServices = null)
|
||||
public static TestServer CreateServer(Action<IApplicationBuilder> builder, string applicationWebSiteName)
|
||||
{
|
||||
return CreateServices(applicationWebSiteName, WebsitesDirectoryPath, newServices);
|
||||
return CreateServer(builder, applicationWebSiteName, applicationPath: null);
|
||||
}
|
||||
|
||||
public static IServiceProvider CreateServices(string applicationWebSiteName, string applicationPath, IServiceCollection newServices = null)
|
||||
public static TestServer CreateServer(
|
||||
Action<IApplicationBuilder> builder,
|
||||
string applicationWebSiteName,
|
||||
string applicationPath)
|
||||
{
|
||||
var originalProvider = CallContextServiceLocator.Locator.ServiceProvider;
|
||||
var appEnvironment = originalProvider.GetRequiredService<IApplicationEnvironment>();
|
||||
return CreateServer(builder, applicationWebSiteName, applicationPath, configureServices: null);
|
||||
}
|
||||
|
||||
public static TestServer CreateServer(
|
||||
Action<IApplicationBuilder> builder,
|
||||
string applicationWebSiteName,
|
||||
Action<IServiceCollection> configureServices)
|
||||
{
|
||||
return CreateServer(
|
||||
builder,
|
||||
applicationWebSiteName,
|
||||
applicationPath: null,
|
||||
configureServices: configureServices);
|
||||
}
|
||||
|
||||
private static TestServer CreateServer(
|
||||
Action<IApplicationBuilder> builder,
|
||||
string applicationWebSiteName,
|
||||
string applicationPath,
|
||||
Action<IServiceCollection> configureServices)
|
||||
{
|
||||
return TestServer.Create(
|
||||
builder,
|
||||
services => AddServices(services, applicationWebSiteName, applicationPath, configureServices));
|
||||
}
|
||||
|
||||
private static void AddServices(
|
||||
IServiceCollection services,
|
||||
string applicationWebSiteName,
|
||||
string applicationPath,
|
||||
Action<IServiceCollection> configureServices)
|
||||
{
|
||||
applicationPath = applicationPath ?? WebsitesDirectoryPath;
|
||||
|
||||
// Get current IApplicationEnvironment; likely added by the host.
|
||||
var provider = services.BuildServiceProvider();
|
||||
var originalEnvironment = provider.GetRequiredService<IApplicationEnvironment>();
|
||||
|
||||
// When an application executes in a regular context, the application base path points to the root
|
||||
// directory where the application is located, for example MvcSample.Web. However, when executing
|
||||
// an aplication as part of a test, the ApplicationBasePath of the IApplicationEnvironment points
|
||||
// an application as part of a test, the ApplicationBasePath of the IApplicationEnvironment points
|
||||
// to the root folder of the test project.
|
||||
// To compensate for this, we need to calculate the original path and override the application
|
||||
// environment value so that components like the view engine work properly in the context of the
|
||||
// test.
|
||||
var appBasePath = CalculateApplicationBasePath(appEnvironment, applicationWebSiteName, applicationPath);
|
||||
var applicationBasePath = CalculateApplicationBasePath(
|
||||
originalEnvironment,
|
||||
applicationWebSiteName,
|
||||
applicationPath);
|
||||
var environment = new TestApplicationEnvironment(
|
||||
originalEnvironment,
|
||||
applicationBasePath,
|
||||
applicationWebSiteName);
|
||||
services.AddInstance<IApplicationEnvironment>(environment);
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddInstance(
|
||||
typeof(IApplicationEnvironment),
|
||||
new TestApplicationEnvironment(appEnvironment, appBasePath, applicationWebSiteName));
|
||||
// Injecting a custom assembly provider. Overrides AddMvc() because that uses TryAdd().
|
||||
var assemblyProvider = CreateAssemblyProvider(applicationWebSiteName);
|
||||
services.AddInstance<IAssemblyProvider>(assemblyProvider);
|
||||
|
||||
// Injecting a custom assembly provider via configuration setting. It's not good enough to just
|
||||
// add the service directly since it's registered by MVC.
|
||||
var providerType = CreateAssemblyProviderType(applicationWebSiteName);
|
||||
|
||||
var configuration = new TestConfigurationProvider();
|
||||
configuration.Configuration.Set(
|
||||
typeof(IAssemblyProvider).FullName,
|
||||
providerType.AssemblyQualifiedName);
|
||||
|
||||
services.AddInstance(
|
||||
typeof(ITestConfigurationProvider),
|
||||
configuration);
|
||||
|
||||
services.AddInstance(
|
||||
typeof(ILoggerFactory),
|
||||
new LoggerFactory());
|
||||
|
||||
if (newServices != null)
|
||||
if (configureServices != null)
|
||||
{
|
||||
services.Add(newServices);
|
||||
configureServices(services);
|
||||
}
|
||||
|
||||
return BuildFallbackServiceProvider(services, originalProvider);
|
||||
}
|
||||
|
||||
// Calculate the path relative to the application base path.
|
||||
public static string CalculateApplicationBasePath(IApplicationEnvironment appEnvironment,
|
||||
string applicationWebSiteName, string websitePath)
|
||||
private static string CalculateApplicationBasePath(
|
||||
IApplicationEnvironment appEnvironment,
|
||||
string applicationWebSiteName,
|
||||
string websitePath)
|
||||
{
|
||||
// Mvc/test/WebSites/applicationWebSiteName
|
||||
return Path.GetFullPath(
|
||||
Path.Combine(appEnvironment.ApplicationBasePath, websitePath, applicationWebSiteName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a disposable action that replaces the service provider <see cref="CallContextServiceLocator.Locator"/>
|
||||
/// with the passed in service that is switched back on <see cref="IDisposable.Dispose"/>.
|
||||
/// </summary>
|
||||
/// <remarks>This is required for config since it uses the static property to get to
|
||||
/// <see cref="IApplicationEnvironment"/>.</remarks>
|
||||
public static IDisposable ReplaceCallContextServiceLocationService(IServiceProvider serviceProvider)
|
||||
{
|
||||
return new CallContextProviderAction(serviceProvider);
|
||||
}
|
||||
|
||||
private static Type CreateAssemblyProviderType(string siteName)
|
||||
private static IAssemblyProvider CreateAssemblyProvider(string siteName)
|
||||
{
|
||||
// Creates a service type that will limit MVC to only the controllers in the test site.
|
||||
// We only want this to happen when running in proc.
|
||||
// We only want this to happen when running in-process.
|
||||
var assembly = Assembly.Load(new AssemblyName(siteName));
|
||||
|
||||
var providerType = typeof(TestAssemblyProvider<>).MakeGenericType(assembly.GetExportedTypes()[0]);
|
||||
return providerType;
|
||||
}
|
||||
|
||||
private sealed class CallContextProviderAction : IDisposable
|
||||
{
|
||||
private readonly IServiceProvider _originalProvider;
|
||||
|
||||
public CallContextProviderAction(IServiceProvider provider)
|
||||
var provider = new FixedSetAssemblyProvider
|
||||
{
|
||||
_originalProvider = CallContextServiceLocator.Locator.ServiceProvider;
|
||||
CallContextServiceLocator.Locator.ServiceProvider = provider;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
CallContextServiceLocator.Locator.ServiceProvider = _originalProvider;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Kill this code
|
||||
private static IServiceProvider BuildFallbackServiceProvider(IEnumerable<ServiceDescriptor> services, IServiceProvider fallback)
|
||||
{
|
||||
var sc = HostingServices.Create(fallback);
|
||||
sc.Add(services);
|
||||
|
||||
// Build the manifest
|
||||
var manifestTypes = services.Where(t => t.ServiceType.GetTypeInfo().GenericTypeParameters.Length == 0
|
||||
&& t.ServiceType != typeof(IServiceManifest)
|
||||
&& t.ServiceType != typeof(IServiceProvider))
|
||||
.Select(t => t.ServiceType).Distinct();
|
||||
sc.AddInstance<IServiceManifest>(new ServiceManifest(manifestTypes, fallback.GetRequiredService<IServiceManifest>()));
|
||||
return sc.BuildServiceProvider();
|
||||
}
|
||||
|
||||
private class ServiceManifest : IServiceManifest
|
||||
{
|
||||
public ServiceManifest(IEnumerable<Type> services, IServiceManifest fallback = null)
|
||||
{
|
||||
Services = services;
|
||||
if (fallback != null)
|
||||
CandidateAssemblies =
|
||||
{
|
||||
Services = Services.Concat(fallback.Services).Distinct();
|
||||
}
|
||||
}
|
||||
assembly,
|
||||
},
|
||||
};
|
||||
|
||||
public IEnumerable<Type> Services { get; private set; }
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ using System.Net.Http;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -16,14 +15,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class TryValidateModelTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ValidationWebSite));
|
||||
private const string SiteName = nameof(ValidationWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new ValidationWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task TryValidateModel_ClearParameterValidationError_ReturnsErrorsForInvalidProperties()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "{ \"Price\": 2, \"Contact\": \"acvrdzersaererererfdsfdsfdsfsdf\", "+
|
||||
"\"ProductDetails\": {\"Detail1\": \"d1\", \"Detail2\": \"d2\", \"Detail3\": \"d3\"}}";
|
||||
|
|
@ -55,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryValidateModel_InvalidTypeOnDerivedModel_ReturnsErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url =
|
||||
"http://localhost/ModelMetadataTypeValidation/TryValidateModelSoftwareViewModelWithPrefix";
|
||||
|
|
@ -74,7 +73,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task TryValidateModel_ValidDerivedModel_ReturnsEmptyResponseBody()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var url =
|
||||
"http://localhost/ModelMetadataTypeValidation/TryValidateModelValidModelNoPrefix";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ValueProvidersWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -12,14 +11,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ValueProviderTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(ValueProvidersWebSite));
|
||||
private const string SiteName = nameof(ValueProvidersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ValueProviderFactories_AreVisitedInSequentialOrder_ForValueProviders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -33,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ValueProviderFactories_ReturnsValuesFromQueryValueProvider()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -47,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ValueProviderFactories_ReturnsValuesFromRouteValueProvider()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -67,7 +66,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ValueProvider_DeserializesEnumsWithFlags(string url, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -15,8 +14,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class VersioningTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices("VersioningWebSite");
|
||||
private readonly Action<IApplicationBuilder> _app = new VersioningWebSite.Startup().Configure;
|
||||
private const string SiteName = nameof(VersioningWebSite);
|
||||
readonly Action<IApplicationBuilder> _app = new VersioningWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
[InlineData("1")]
|
||||
|
|
@ -24,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_WithVersionedRoutes_IsNotAmbiguous(string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task AttributeRoutedAction_WithAmbiguousVersionedRoutes_CanBeDisambiguatedUsingOrder(string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var query = "?version=" + version;
|
||||
var message = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/Addresses/All" + query);
|
||||
|
|
@ -74,7 +73,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1Operations_OnTheSameController_WithNoVersionSpecified()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -97,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1Operations_OnTheSameController_WithVersionSpecified()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -118,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheSameController()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -139,7 +138,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheSameController_WithVersionSpecified()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -168,7 +167,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachOtherVersionOperations_OnTheSameController(string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -194,7 +193,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanNotReachOtherVersionOperations_OnTheSameController_WithNoVersionSpecified()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -221,7 +220,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -249,7 +248,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanNotReachOtherVersionOperationsWithParameters_OnTheSameController_WithNoVersionSpecified(string method)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -270,7 +269,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanUseOrderToDisambiguate_OverlappingVersionRanges(string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -294,7 +293,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_OverlappingVersionRanges_FallsBackToLowerOrderAction(string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -318,7 +317,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1Operations_OnTheOriginalController_WithNoVersionSpecified(string method, string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -341,7 +340,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1Operations_OnTheOriginalController_WithVersionSpecified(string method, string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -365,7 +364,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheOriginalController(string method, string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -388,7 +387,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachV1OperationsWithParameters_OnTheOriginalController_WithVersionSpecified(string method, string action)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -409,7 +408,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanReachOtherVersionOperationsWithParameters_OnTheV2Controller()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -433,7 +432,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnTheSameAction(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -456,7 +455,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnDifferentActions(string url, string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -479,7 +478,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanHaveTwoRoutesWithVersionOnTheUrl_OnDifferentActions_WithInlineConstraint(string url, string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -505,7 +504,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanProvideVersioningInformation_UsingPlainActionConstraint(string url, string query, string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -526,7 +525,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_ConstraintOrder_IsRespected()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -547,7 +546,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_CanUseConstraintOrder_ToChangeSelectedAction()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -570,7 +569,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task VersionedApi_MultipleVersionsUsingAttributeRouting_OnTheSameMethod(string version)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var path = "/" + version + "/Vouchers?version=" + version;
|
||||
|
||||
|
|
@ -591,7 +590,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
Assert.Equal(path, actualUrl);
|
||||
}
|
||||
|
||||
// See TestResponseGenerator in RoutingWebSite for the code that generates this data.
|
||||
private class RoutingResult
|
||||
{
|
||||
public string[] ExpectedUrls { get; set; }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using ViewComponentWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -13,7 +12,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ViewComponentTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("ViewComponentWebSite");
|
||||
private const string SiteName = nameof(ViewComponentWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
public static IEnumerable<object[]> ViewViewComponents_AreRenderedCorrectlyData
|
||||
|
|
@ -42,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[MemberData(nameof(ViewViewComponents_AreRenderedCorrectlyData))]
|
||||
public async Task ViewViewComponents_AreRenderedCorrectly(string actionName, string expected)
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -55,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ViewComponents_SupportsValueType()
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -74,7 +73,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[InlineData("http://localhost/Home/ViewComponentWithEnumerableModelUsingUnion", "Union")]
|
||||
public async Task ViewComponents_SupportsEnumerableModel(string url, string linqQueryType)
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -93,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[InlineData("ViewComponentWebSite.Namespace2.SameName")]
|
||||
public async Task ViewComponents_FullName(string name)
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -106,7 +105,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ViewComponents_ShortNameUsedForViewLookup()
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var name = "ViewComponentWebSite.Integer";
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using RazorWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -14,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class ViewEngineTests
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices("RazorWebSite");
|
||||
private const string SiteName = nameof(RazorWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
|
||||
public static IEnumerable<object[]> RazorView_ExecutesPageAndLayoutData
|
||||
|
|
@ -63,7 +62,7 @@ ViewWithNestedLayout-Content
|
|||
[MemberData(nameof(RazorView_ExecutesPageAndLayoutData))]
|
||||
public async Task RazorView_ExecutesPageAndLayout(string actionName, string expected)
|
||||
{
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -84,7 +83,7 @@ ViewWithNestedLayout-Content
|
|||
"",
|
||||
"</partial2>",
|
||||
"test-value");
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -99,7 +98,7 @@ ViewWithNestedLayout-Content
|
|||
{
|
||||
// Arrange
|
||||
var expected = "HelloWorld";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -118,7 +117,7 @@ ViewWithNestedLayout-Content
|
|||
|
||||
partial-content
|
||||
component-content";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -154,7 +153,7 @@ component-content";
|
|||
public async Task RazorViewEngine_UsesViewExpandersForViewsAndPartials(string value, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -182,7 +181,7 @@ component-content";
|
|||
public async Task ViewLocationExpanders_PassesInIsPartialToViewLocationExpanderContext(string action, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -247,7 +246,7 @@ ViewWithNestedLayout-Content
|
|||
public async Task RazorViewEngine_RendersPartialViews(string actionName, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -266,7 +265,7 @@ ViewWithNestedLayout-Content
|
|||
"",
|
||||
"~/Views/NestedViewStarts/NestedViewStarts/Layout.cshtml",
|
||||
"index-content");
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -302,7 +301,7 @@ View With Layout
|
|||
public async Task RazorViewEngine_UsesExpandersForLayouts(string value, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -320,7 +319,7 @@ View With Layout
|
|||
var expected =
|
||||
@"<view-start>Hello Controller-Person</view-start>
|
||||
<page>Hello Controller-Person</page>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var target = "http://localhost/NestedGlobalImports";
|
||||
|
||||
|
|
@ -342,7 +341,7 @@ Page Content
|
|||
<component-title>ViewComponent With Title</component-title>
|
||||
<component-body>
|
||||
Component With Layout</component-body>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -357,7 +356,7 @@ Component With Layout</component-body>";
|
|||
{
|
||||
// Arrange
|
||||
var expected = @"<page-content>ViewComponent With ViewStart</page-content>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -372,7 +371,7 @@ Component With Layout</component-body>";
|
|||
{
|
||||
// Arrange
|
||||
var expected = "Partial that does not specify Layout";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -391,7 +390,7 @@ Component With Layout</component-body>";
|
|||
Partial that specifies Layout
|
||||
</layout-for-viewstart-with-layout>Partial that does not specify Layout
|
||||
</layout-for-viewstart-with-layout>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -411,7 +410,7 @@ Partial that specifies Layout
|
|||
</layout-for-viewstart-with-layout>
|
||||
Partial that does not specify Layout
|
||||
</layout-for-viewstart-with-layout>";
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -427,7 +426,7 @@ Partial that does not specify Layout
|
|||
// Arrange
|
||||
var expected = await GetType().GetTypeInfo().Assembly
|
||||
.ReadResourceAsStringAsync("compiler/resources/ViewEngineController.ViewWithPaths.txt");
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -5,21 +5,20 @@ using System;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class WebApiCompatShimActionResultTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(WebApiCompatShimWebSite));
|
||||
private const string SiteName = nameof(WebApiCompatShimWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ApiController_BadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -33,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_BadRequestMessage()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_BadRequestModelState()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected = "{\"Message\":\"The request is invalid.\",\"ModelState\":{\"product.Name\":[\"Name is required.\"]}}";
|
||||
|
|
@ -67,7 +66,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Conflict()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -81,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Content()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -97,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreatedRelative()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -114,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreatedAbsolute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -131,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreatedQualified()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -148,7 +147,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreatedUri()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -165,7 +164,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreatedAtRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -182,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_InternalServerError()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -196,7 +195,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_InternalServerErrorException()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -212,7 +211,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Json()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -228,7 +227,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_JsonSettings()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected =
|
||||
|
|
@ -249,7 +248,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_JsonSettingsEncoding()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected =
|
||||
|
|
@ -271,7 +270,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_NotFound()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -285,7 +284,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Ok()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -299,7 +298,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_OkContent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -315,7 +314,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_RedirectString()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -330,7 +329,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_RedirectUri()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -345,7 +344,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_ResponseMessage()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -360,7 +359,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_StatusCode()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -14,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class WebApiCompatShimActionSelectionTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(WebApiCompatShimWebSite));
|
||||
private const string SiteName = nameof(WebApiCompatShimWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -28,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction(string httpMethod, string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -57,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction(string httpMethod, string actionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -79,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_MismatchedVerb()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -97,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction_DefaultVerbIsPost_Success()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -119,7 +118,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_DefaultVerbIsPost_Success()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -141,7 +140,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_UnnamedAction_DefaultVerbIsPost_VerbMismatch()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -159,7 +158,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromPrefix_NamedAction_DefaultVerbIsPost_VerbMismatch()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -177,7 +176,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_UnnamedAction_Success()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -199,7 +198,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_NamedAction_Success()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -221,7 +220,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_UnnamedAction_VerbMismatch()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -239,7 +238,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_TakesHttpMethodFromMethodName_NotActionName_NamedAction_VerbMismatch()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -257,7 +256,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_HttpMethodOverride_UnnamedAction_Success()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -279,7 +278,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_HttpMethodOverride_NamedAction_Success()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -301,7 +300,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_HttpMethodOverride_UnnamedAction_VerbMismatch()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -319,7 +318,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebAPIConvention_HttpMethodOverride_NamedAction_VerbMismatch()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -368,7 +367,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_OverloadedAction_WithUnnamedAction(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -395,7 +394,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_OverloadedAction_NonIdRouteParameter(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -419,7 +418,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_OverloadedAction_Parameter_Casing(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -446,7 +445,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_RouteWithActionName(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -473,7 +472,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_RouteWithActionName_Casing(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -498,7 +497,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_RouteWithoutActionName(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -526,7 +525,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_ModelBindingParameterAttribute_AreAppliedWhenSelectingActions(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -550,7 +549,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_ActionsThatHaveSubsetOfRouteParameters_AreConsideredForSelection(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
@ -572,7 +571,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_RequestToAmbiguousAction_OnDefaultRoute()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), "http://localhost/api/Admin/Test?name=mario");
|
||||
|
|
@ -593,7 +592,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task LegacyActionSelection_SelectAction_ReturnsActionDescriptor_ForEnumParameterOverloads(string httpMethod, string requestUrl, string expectedActionName)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(new HttpMethod(httpMethod), "http://localhost/" + requestUrl);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ using System.Net.Http.Headers;
|
|||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -19,14 +18,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class WebApiCompatShimBasicTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(WebApiCompatShimWebSite));
|
||||
private const string SiteName = nameof(WebApiCompatShimWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task ApiController_Activates_HttpContextAndUser()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -44,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Activates_UrlHelper()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -64,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task Options_SetsDefaultFormatters()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected = new string[]
|
||||
|
|
@ -91,7 +90,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionThrowsHttpResponseException_WithStatusCode()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -108,7 +107,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionThrowsHttpResponseException_WithResponse()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -126,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionThrowsHttpResponseException_EnsureGlobalHttpresponseExceptionActionFilter_IsInvoked()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -144,7 +143,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ActionThrowsHttpResponseException_EnsureGlobalFilterConvention_IsApplied()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -163,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CanValidateCustomObjectWithPrefix_Fails()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -180,7 +179,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CanValidateCustomObject_IsSuccessFul()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -194,7 +193,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CanValidateCustomObject_Fails()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -210,7 +209,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_RequestProperty()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected =
|
||||
|
|
@ -232,7 +231,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_RequestParameter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected =
|
||||
|
|
@ -254,7 +253,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_ResponseReturned()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected =
|
||||
|
|
@ -280,7 +279,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_ExplicitChunkedEncoding_IsIgnored()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var expected =
|
||||
|
|
@ -325,7 +324,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreateResponse_Conneg(string accept, string mediaType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -350,7 +349,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreateResponse_HardcodedMediaType(string mediaType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -375,7 +374,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreateResponse_Conneg_Error(string accept, string mediaType)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -398,7 +397,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_CreateResponse_HardcodedFormatter()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
|
|
@ -424,7 +423,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebApiRouting_AccessMvcController(string url, HttpStatusCode expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
|
|
@ -442,7 +441,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task WebApiRouting_AccessWebApiController(string url, HttpStatusCode expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
|
|
@ -458,7 +457,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Returns_ByteArrayContent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedBody = "Hello from ByteArrayContent!!";
|
||||
|
||||
|
|
@ -478,7 +477,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Returns_StreamContent()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedBody = "This content is from a file";
|
||||
|
||||
|
|
@ -502,7 +501,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Returns_PushStreamContent(string action, string expectedBody)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
|
|
@ -521,7 +520,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_Returns_PushStreamContentWithCustomHeaders()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var expectedBody = "Hello from PushStreamContent with custom headers!!";
|
||||
var multipleValues = new[] { "value1", "value2" };
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Net.Http;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class WebApiCompatShimParameterBindingTest
|
||||
{
|
||||
private readonly IServiceProvider _provider = TestHelper.CreateServices(nameof(WebApiCompatShimWebSite));
|
||||
private const string SiteName = nameof(WebApiCompatShimWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new WebApiCompatShimWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -25,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_SimpleParameter_Default_ReadsFromUrl(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
|
|
@ -43,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_SimpleParameter_Default_DoesNotReadFormData()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/api/Blog/Employees/PostByIdDefault";
|
||||
|
|
@ -68,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_SimpleParameter_ModelBinder_ReadsFromUrl(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
|
|
@ -86,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_SimpleParameter_ModelBinder_ReadsFromFormData()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/api/Blog/Employees/PostByIdModelBinder";
|
||||
|
|
@ -111,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_SimpleParameter_FromQuery_ReadsFromQueryNotRouteData(string url, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
|
|
@ -129,7 +128,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_SimpleParameter_FromQuery_DoesNotReadFormData()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/api/Blog/Employees/PostByIdFromQuery";
|
||||
|
|
@ -152,7 +151,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_ComplexParameter_Default_ReadsFromBody()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/api/Blog/Employees/PutEmployeeDefault";
|
||||
|
|
@ -177,7 +176,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_ComplexParameter_ModelBinder_ReadsFormAndUrl()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/api/Blog/Employees/PutEmployeeModelBinder/5";
|
||||
|
|
@ -201,7 +200,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ApiController_TwoParameters_DefaultSources()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_provider, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
|
||||
var url = "http://localhost/api/Blog/Employees/PutEmployeeBothDefault?name=Name_Override";
|
||||
|
|
|
|||
|
|
@ -5,18 +5,16 @@ using System;
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class XmlDataContractSerializerFormattersWrappingTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(XmlFormattersWebSite));
|
||||
private const string SiteName = nameof(XmlFormattersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -25,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_ValueTypes(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
@ -48,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_NonWrappedTypes(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
@ -71,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_NonWrappedTypes_Empty(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
@ -93,7 +91,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_NonWrappedTypes_NullInstance(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
@ -115,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_WrappedTypes(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
@ -139,7 +137,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_WrappedTypes_Empty(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
@ -161,7 +159,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_WrappedTypes_NullInstance(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
@ -181,7 +179,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_IEnumerableOf_SerializableErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/IEnumerable/SerializableErrors");
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-dcs"));
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ using System.Runtime.Serialization;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using XmlFormattersWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -20,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class XmlDataContractSerializerInputFormatterTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(XmlFormattersWebSite));
|
||||
private const string SiteName = nameof(XmlFormattersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
private readonly string errorMessageFormat = string.Format(
|
||||
"{{1}}:{0} does not recognize '{1}', so instead use '{2}' with '{3}' set to '{4}' for value " +
|
||||
|
|
@ -35,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ThrowsOnInvalidInput_AndAddsToModelState()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "Not a valid xml document";
|
||||
var content = new StringContent(input, Encoding.UTF8, "application/xml-dcs");
|
||||
|
|
@ -59,7 +58,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task RequiredDataIsProvided_AndModelIsBound_AndHasRequiredAttributeValidationErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml-dcs"));
|
||||
var input = "<Store xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite\" " +
|
||||
|
|
@ -103,7 +102,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task DataMissingForReferneceTypeProperties_AndModelIsBound_AndHasMixedValidationErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml-dcs"));
|
||||
var input = "<Store xmlns=\"http://schemas.datacontract.org/2004/07/XmlFormattersWebSite\"" +
|
||||
|
|
|
|||
|
|
@ -7,26 +7,20 @@ using System.Net.Http;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class XmlOutputFormatterTests
|
||||
{
|
||||
private readonly IServiceProvider _services;
|
||||
private const string SiteName = nameof(FormatterWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new FormatterWebSite.Startup().Configure;
|
||||
|
||||
public XmlOutputFormatterTests()
|
||||
{
|
||||
_services = TestHelper.CreateServices("FormatterWebSite");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task XmlDataContractSerializerOutputFormatterIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/Home/GetDummyClass?sampleInput=10");
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8"));
|
||||
|
|
@ -46,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task XmlSerializerOutputFormatterIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/XmlSerializer/GetDummyClass?sampleInput=10");
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml;charset=utf-8"));
|
||||
|
|
@ -65,7 +59,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task XmlSerializerFailsAndDataContractSerializerIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Post,
|
||||
"http://localhost/DataContractSerializer/GetPerson?name=HelloWorld");
|
||||
|
|
@ -86,7 +80,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task XmlSerializerOutputFormatter_WhenDerivedClassIsReturned()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post, "http://localhost/XmlSerializer/GetDerivedDummyClass?sampleInput=10");
|
||||
|
|
@ -107,7 +101,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task XmlDataContractSerializerOutputFormatter_WhenDerivedClassIsReturned()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post, "http://localhost/Home/GetDerivedDummyClass?sampleInput=10");
|
||||
|
|
@ -128,7 +122,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task XmlSerializerFormatter_DoesNotWriteDictionaryObjects()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(
|
||||
HttpMethod.Post, "http://localhost/XmlSerializer/GetDictionary");
|
||||
|
|
|
|||
|
|
@ -5,18 +5,16 @@ using System;
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Xml;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class XmlSerializerFormattersWrappingTest
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(XmlFormattersWebSite));
|
||||
private const string SiteName = nameof(XmlFormattersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
|
||||
|
||||
[Theory]
|
||||
|
|
@ -25,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_ValueTypes(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
@ -48,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_NonWrappedTypes(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
@ -71,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_NonWrappedTypes_NullInstance(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
@ -93,7 +91,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_NonWrappedTypes_Empty(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
@ -115,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_WrappedTypes(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
@ -139,7 +137,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_WrappedTypes_Empty(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
@ -162,7 +160,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_WrappedTypes_NullInstance(string url)
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
@ -183,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task CanWrite_IEnumerableOf_SerializableErrors()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/IEnumerable/SerializableErrors");
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml-xmlser"));
|
||||
|
|
|
|||
|
|
@ -7,21 +7,20 @@ using System.Net.Http;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class XmlSerializerInputFormatterTests
|
||||
{
|
||||
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(XmlFormattersWebSite));
|
||||
private const string SiteName = nameof(XmlFormattersWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public async Task CheckIfXmlSerializerInputFormatterIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var sampleInputInt = 10;
|
||||
var input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
|
|
@ -41,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
public async Task ThrowsOnInvalidInput_AndAddsToModelState()
|
||||
{
|
||||
// Arrange
|
||||
var server = TestServer.Create(_services, _app);
|
||||
var server = TestHelper.CreateServer(_app, SiteName);
|
||||
var client = server.CreateClient();
|
||||
var input = "Not a valid xml document";
|
||||
var content = new StringContent(input, Encoding.UTF8, "application/xml-xmlser");
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
"FormatFilterWebSite": "1.0.0-*",
|
||||
"FormatterWebSite": "1.0.0",
|
||||
"InlineConstraintsWebSite": "1.0.0",
|
||||
"LoggingWebSite": "1.0.0",
|
||||
"LoggingWebSite": "1.0.0",
|
||||
"LowercaseUrlsWebSite": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0",
|
||||
|
|
|
|||
|
|
@ -46,44 +46,6 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Equal(ServiceLifetime.Singleton, services[3].Lifetime);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithControllersAsServices_UsesConfigurationIfSpecified()
|
||||
{
|
||||
// Arrange
|
||||
var collection = new ServiceCollection();
|
||||
var controllerTypes = new[] { typeof(ControllerTypeA), typeof(TypeBController) };
|
||||
var configuration = new Configuration();
|
||||
configuration.Add(new MemoryConfigurationSource());
|
||||
configuration.Set(typeof(IControllerActivator).FullName,
|
||||
typeof(CustomActivator).AssemblyQualifiedName);
|
||||
configuration.Set(typeof(IControllerTypeProvider).FullName,
|
||||
typeof(CustomTypeProvider).AssemblyQualifiedName);
|
||||
|
||||
// Act
|
||||
MvcServiceCollectionExtensions.WithControllersAsServices(collection,
|
||||
controllerTypes,
|
||||
configuration);
|
||||
|
||||
// Assert
|
||||
var services = collection.ToList();
|
||||
Assert.Equal(4, services.Count);
|
||||
Assert.Equal(typeof(ControllerTypeA), services[0].ServiceType);
|
||||
Assert.Equal(typeof(ControllerTypeA), services[0].ImplementationType);
|
||||
Assert.Equal(ServiceLifetime.Transient, services[0].Lifetime);
|
||||
|
||||
Assert.Equal(typeof(TypeBController), services[1].ServiceType);
|
||||
Assert.Equal(typeof(TypeBController), services[1].ImplementationType);
|
||||
Assert.Equal(ServiceLifetime.Transient, services[1].Lifetime);
|
||||
|
||||
Assert.Equal(typeof(IControllerActivator), services[2].ServiceType);
|
||||
Assert.Equal(typeof(CustomActivator), services[2].ImplementationType);
|
||||
Assert.Equal(ServiceLifetime.Transient, services[2].Lifetime);
|
||||
|
||||
Assert.Equal(typeof(IControllerTypeProvider), services[3].ServiceType);
|
||||
Assert.Equal(typeof(CustomTypeProvider), services[3].ImplementationType);
|
||||
Assert.Equal(ServiceLifetime.Singleton, services[3].Lifetime);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithControllersAsServices_ScansControllersFromSpecifiedAssemblies()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.TestConfiguration;
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
|
@ -10,15 +9,13 @@ namespace Microsoft.AspNet.Builder
|
|||
{
|
||||
public static class BuilderExtensions
|
||||
{
|
||||
public static Configuration GetTestConfiguration(this IApplicationBuilder app)
|
||||
public static IConfiguration GetTestConfiguration(this IApplicationBuilder app)
|
||||
{
|
||||
// Unconditionally place CultureReplacerMiddleware as early as possible in the pipeline.
|
||||
app.UseMiddleware<CultureReplacerMiddleware>();
|
||||
|
||||
var configurationProvider = app.ApplicationServices.GetService<ITestConfigurationProvider>();
|
||||
var configuration = configurationProvider == null
|
||||
? new Configuration()
|
||||
: configurationProvider.Configuration;
|
||||
// Until we update all references, return a useful configuration.
|
||||
var configuration = app.ApplicationServices.GetService<IConfiguration>() ?? new Configuration();
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public interface ITestConfigurationProvider
|
||||
{
|
||||
Configuration Configuration { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -2,98 +2,15 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Runtime;
|
||||
|
||||
namespace PrecompilationWebSite
|
||||
{
|
||||
public class RazorPreCompilation : RazorPreCompileModule
|
||||
{
|
||||
public RazorPreCompilation(IServiceProvider provider) : base(ReplaceProvider(provider))
|
||||
public RazorPreCompilation(IServiceProvider provider)
|
||||
: base(provider)
|
||||
{
|
||||
}
|
||||
|
||||
// We need to construct an IApplicationEnvironment with a base path that that matches this
|
||||
// website, in order to find the razor files. This is needed because we don't have a guarantee that
|
||||
// the base path of the current app is this site (ex: functional tests).
|
||||
public static IServiceProvider ReplaceProvider(IServiceProvider provider)
|
||||
{
|
||||
var originalEnvironment = provider.GetService<IApplicationEnvironment>();
|
||||
|
||||
var libraryManager = provider.GetService<ILibraryManager>();
|
||||
var info = libraryManager.GetLibraryInformation("PrecompilationWebSite");
|
||||
var directory = Path.GetDirectoryName(info.Path);
|
||||
|
||||
var precompilationApplicationEnvironment = new PrecompilationApplicationEnvironment(
|
||||
originalEnvironment,
|
||||
directory);
|
||||
|
||||
var collection = HostingServices.Create(provider);
|
||||
collection.AddInstance<IApplicationEnvironment>(precompilationApplicationEnvironment);
|
||||
|
||||
return new DelegatingServiceProvider(provider, collection.BuildServiceProvider());
|
||||
}
|
||||
|
||||
private class PrecompilationApplicationEnvironment : IApplicationEnvironment
|
||||
{
|
||||
private readonly IApplicationEnvironment _originalApplicationEnvironment;
|
||||
private readonly string _applicationBasePath;
|
||||
|
||||
public PrecompilationApplicationEnvironment(IApplicationEnvironment original, string appBasePath)
|
||||
{
|
||||
_originalApplicationEnvironment = original;
|
||||
_applicationBasePath = appBasePath;
|
||||
}
|
||||
|
||||
public string ApplicationName
|
||||
{
|
||||
get { return _originalApplicationEnvironment.ApplicationName; }
|
||||
}
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return _originalApplicationEnvironment.Version; }
|
||||
}
|
||||
|
||||
public string ApplicationBasePath
|
||||
{
|
||||
get { return _applicationBasePath; }
|
||||
}
|
||||
|
||||
public string Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return _originalApplicationEnvironment.Configuration;
|
||||
}
|
||||
}
|
||||
|
||||
public FrameworkName RuntimeFramework
|
||||
{
|
||||
get { return _originalApplicationEnvironment.RuntimeFramework; }
|
||||
}
|
||||
}
|
||||
|
||||
private class DelegatingServiceProvider : IServiceProvider
|
||||
{
|
||||
private readonly IServiceProvider _fallback;
|
||||
private readonly IServiceProvider _services;
|
||||
|
||||
public DelegatingServiceProvider(IServiceProvider fallback, IServiceProvider services)
|
||||
{
|
||||
_fallback = fallback;
|
||||
_services = services;
|
||||
}
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return _services.GetService(serviceType) ?? _fallback.GetService(serviceType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue