Ejemplo n.º 1
0
        /// <summary>
        /// Configures the OWIN pipeline for a test.
        /// </summary>
        /// <param name="owinAppBuilder"></param>
        /// <param name="iocContainer">A SimpleInjector IOC container.</param>
        /// <param name="odataConfigAction">Optional configuration for <see cref="ODataServerConfigurer"/>.</param>
        protected virtual void ConfigureOwinPipeline(IAppBuilder owinAppBuilder, Container iocContainer, Action <ODataServerConfigurer> odataConfigAction = null)
        {
            // Test class name is the app name
            owinAppBuilder.Properties["host.AppName"] = GetType().FullName;
            owinAppBuilder.Properties["EntityRepository.InUnitTest"] = true;             // In case any test-conditional logic is needed

            // HTTP and trace logging
            ConfigureLogging(owinAppBuilder, out _logManager, out _tracerFactory);

            // Request filter method, useful breakpoint for debugging
            owinAppBuilder.Use(TestRequestFilter);

            // Add Web API to the Owin pipeline
            HttpConfiguration webApiConfig = new HttpConfiguration();

            //webApiConfig.EnableSystemDiagnosticsTracing();
            // Use SimpleInjector as the web API DependencyResolver
            webApiConfig.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(iocContainer);
            HttpServer webApiServer = new HttpServer(webApiConfig);

            // Configure EntityRepository.ODataServer controllers
            var oDataServerConfigurer = new ODataServerConfigurer(webApiConfig);

            if (odataConfigAction != null)
            {
                odataConfigAction(oDataServerConfigurer);
            }
            oDataServerConfigurer.AddStandardEntitySetControllers();
            oDataServerConfigurer.ConfigureODataRoutes(webApiServer.Configuration.Routes, "ODataRoute", "odata", webApiServer);

            owinAppBuilder.UseWebApi(webApiServer);

            // Verify that DI config is valid; and initialize everything
            iocContainer.Verify();
        }
Ejemplo n.º 2
0
        internal static void ConfigureODataService(HttpServer server)
        {
            // Configure OData controllers
            var oDataServerConfigurer = new ODataServerConfigurer(server.Configuration);

            oDataServerConfigurer.AddStandardEntitySetControllers();
            oDataServerConfigurer.ConfigureODataRoutes(server.Configuration.Routes, "ODataRoute", "odata", server);
        }
Ejemplo n.º 3
0
        internal static void ConfigureODataService(HttpConfiguration webApiConfig, HttpServer webApiServer)
        {
            // Configure OData controllers
            var oDataServerConfigurer = new ODataServerConfigurer(webApiConfig);

            // Just to prove that regular controller classes can be added when customization is needed
            // However, this isn't needed, b/c the dependency injector normally picks up all controllers in the assembly.
            //oDataServerConfigurer.AddEntitySetController("Projects", typeof(Project), typeof(ProjectsController));
            //oDataServerConfigurer.AddEntitySetController("Users", typeof(User), typeof(UsersController));

            oDataServerConfigurer.AddStandardEntitySetControllers(DbSetControllerSelector);

            // TODO: Remove this - using to compare ODataConventionModelBuilder's EDM to what EF creates.
            var odataModelBuilder = new ODataConventionModelBuilder(webApiConfig);

            odataModelBuilder.ConfigureFromContainer(oDataServerConfigurer.ContainerMetadata);

            oDataServerConfigurer.ConfigureODataRoutes(webApiConfig.Routes, "ODataRoute", ODataRoute, webApiServer,
                                                       // TODO: Remove this arg
                                                       odataModelBuilder.GetEdmModel());
        }
Ejemplo n.º 4
0
		/// <summary>
		/// Configures the OWIN pipeline for a test.
		/// </summary>
		/// <param name="owinAppBuilder"></param>
		/// <param name="iocContainer">A SimpleInjector IOC container.</param>
		/// <param name="odataConfigAction">Optional configuration for <see cref="ODataServerConfigurer"/>.</param>
		protected virtual void ConfigureOwinPipeline(IAppBuilder owinAppBuilder, Container iocContainer, Action<ODataServerConfigurer> odataConfigAction = null)
		{
			// Test class name is the app name
			owinAppBuilder.Properties["host.AppName"] = GetType().FullName;
			owinAppBuilder.Properties["EntityRepository.InUnitTest"] = true; // In case any test-conditional logic is needed

			// HTTP and trace logging
			ConfigureLogging(owinAppBuilder, out _logManager, out _tracerFactory);

			// Request filter method, useful breakpoint for debugging
			owinAppBuilder.Use(TestRequestFilter);

			// Add Web API to the Owin pipeline
			HttpConfiguration webApiConfig = new HttpConfiguration();
			//webApiConfig.EnableSystemDiagnosticsTracing();
			// Use SimpleInjector as the web API DependencyResolver
			webApiConfig.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(iocContainer);
			HttpServer webApiServer = new HttpServer(webApiConfig);

			// Configure EntityRepository.ODataServer controllers
			var oDataServerConfigurer = new ODataServerConfigurer(webApiConfig);
			if (odataConfigAction != null)
			{
				odataConfigAction(oDataServerConfigurer);
			}
			oDataServerConfigurer.AddStandardEntitySetControllers();
			oDataServerConfigurer.ConfigureODataRoutes(webApiServer.Configuration.Routes, "ODataRoute", "odata", webApiServer);

			owinAppBuilder.UseWebApi(webApiServer);

			// Verify that DI config is valid; and initialize everything
			iocContainer.Verify();
		}