/// <summary> /// Initializes a new instance of the routing configuration class. /// </summary> /// <returns>A new instance of the routing configuration class.</returns> internal static HttpConfiguration CreateWithRootContainerAndTypes(string routeName = null, Action <IContainerBuilder> configureAction = null, params Type[] types) { HttpConfiguration configuration = CreateWithRootContainer(routeName, configureAction); TestAssemblyResolver resolver = new TestAssemblyResolver(new MockAssembly(types)); configuration.Services.Replace(typeof(IAssembliesResolver), resolver); return(configuration); }
/// <summary> /// Initializes a new instance of the routing configuration class. /// </summary> /// <returns>A new instance of the routing configuration class.</returns> internal static HttpConfiguration CreateWithTypes(params Type[] types) { HttpConfiguration configuration = Create(); TestAssemblyResolver resolver = new TestAssemblyResolver(new MockAssembly(types)); configuration.Services.Replace(typeof(IAssembliesResolver), resolver); configuration.Count().OrderBy().Filter().Expand().MaxTop(null); return(configuration); }
/// <summary> /// Create an TestServer. /// </summary> /// <param name="controllers">The controllers to use.</param> /// <param name="configureAction">The route configuration.</param> /// <param name="configureAction">The route configuration action.</param> /// <returns>An TestServer.</returns> private static HttpServer Create( HttpConfiguration configuration, Type[] controllers, Action <HttpConfiguration> configureAction) { if (controllers != null) { TestAssemblyResolver resolver = new TestAssemblyResolver(new MockAssembly(controllers)); configuration.Services.Replace(typeof(IAssembliesResolver), resolver); } configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; configureAction(configuration); configuration.EnsureInitialized(); return(new HttpServer(configuration)); }
/// <summary> /// Initializes a new instance of the routing configuration class. /// </summary> /// <returns>A new instance of the routing configuration class.</returns> internal static IWebApiAssembliesResolver Create(MockAssembly assembly = null) { IAssembliesResolver resolver = null; if (assembly != null) { resolver = new TestAssemblyResolver(assembly); } else { Mock <IAssembliesResolver> mockAssembliesResolver = new Mock <IAssembliesResolver>(); mockAssembliesResolver .Setup(r => r.GetAssemblies()) .Returns(new Assembly[0]); resolver = mockAssembliesResolver.Object; } return(new WebApiAssembliesResolver(resolver)); }