Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <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);
        }
        public ODataContainmentTest()
        {
            var controllers = new[] { typeof(MyOrdersController) };
            var resolver    = new TestAssemblyResolver(new MockAssembly(controllers));

            _configuration = new HttpConfiguration {
                IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always
            };
            _configuration.Services.Replace(typeof(IAssembliesResolver), resolver);

            _configuration.Count().OrderBy().Filter().Expand().MaxTop(null);
            _configuration.MapODataServiceRoute("odata", "odata", GetEdmModel());
            var server = new HttpServer(_configuration);

            _client = new HttpClient(server);
        }
Exemple #4
0
        /// <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));
        }
Exemple #5
0
        /// <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));
        }