예제 #1
0
        public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();
            var httpServer = new HttpServer(config);

            config.AddApiVersioning();
            config.Select().Expand().Filter().OrderBy().MaxTop(null).Count();

            var modelBuilder = new VersionedODataModelBuilder(config)
            {
                ModelBuilderFactory = () => new ODataConventionModelBuilder().EnableLowerCamelCase(),
                ModelConfigurations =
                {
                    new FlightPlanConfiguration(),
                    new FlightDetailsConfiguration()
                }
            };
            var models       = modelBuilder.GetEdmModels();
            var batchHandler = new DefaultODataBatchHandler(httpServer);
            var conventions  = ODataRoutingConventions.CreateDefault();

            conventions.Insert(0, new CompositeKeyRoutingConvention());

            config.MapVersionedODataRoutes("odata", "data/v{apiVersion}", models, ConfigureODataServices, batchHandler);
            //config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional });
            //config.MapVersionedODataRoutes("odata", "data/v{apiVersion}", models, new DefaultODataPathHandler(),conventions, batchHandler);
        }
예제 #2
0
            /// <summary>
            /// Gets the configuration.
            /// </summary>
            /// <param name="odataModel">The odata model.</param>
            /// <returns></returns>
            public static HttpConfiguration GetConfig(IEdmModel odataModel)
            {
                var config = new HttpConfiguration();

                config.MapHttpAttributeRoutes();

                var pathHandler        = new DefaultODataPathHandler();
                var routingConventions = ODataRoutingConventions.CreateDefaultWithAttributeRouting(config, odataModel);
                var batchHandler       = new DefaultODataBatchHandler(new HttpServer(config));

                config.MapODataServiceRoute(
                    routeName: "ODataService",
                    routePrefix: "api/v1",
                    model: odataModel,
                    pathHandler: pathHandler,
                    routingConventions: routingConventions,
                    batchHandler: batchHandler);
                config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
                config.EnsureInitialized();

                // XML JSON

                var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");

                config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);

                return(config);
            }
        internal static void ConfigureOData(this HttpConfiguration configuration, HttpServer httpServer)
        {
            // BUG: cannot use alt keys and unqualified actions in 5.9.1; may be resolvable in 6.0, but that isn't not supported by API versioning - yet
            // REF: https://github.com/OData/WebApi/issues/636

            //configuration.EnableAlternateKeys( true );
            configuration.EnableCaseInsensitive(true);
            configuration.EnableUnqualifiedNameCall(true);
            configuration.EnableEnumPrefixFree(true);
            configuration.EnableMediaResources();

            var modelConfigurations = configuration.DependencyResolver.GetServices <IModelConfiguration>();
            var builder             = new VersionedODataModelBuilder(configuration)
            {
                ModelBuilderFactory = () => new ODataConventionModelBuilder()
                {
                    Namespace = nameof(Contoso)
                }.EnableLowerCamelCase(),
                OnModelCreated = BuilderExtensions.ApplyAnnotations
            };

            builder.ModelConfigurations.AddRange(modelConfigurations);

            var models       = builder.GetEdmModels();
            var batchHandler = new DefaultODataBatchHandler(httpServer);

            configuration.MapVersionedODataRoutes("odata", RoutePrefix, models, batchHandler);
        }
        public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();
            // Web API configuration and services
            var builder = new ODataConventionModelBuilder();

            config.EnableUnqualifiedNameCall(true);

            config.EnableEnumPrefixFree(true);

            RegisterEntities(ref builder);

            RegisterCustomRoutes(ref builder);

            builder.Namespace = "";

            builder.EnableLowerCamelCase();

            ODataBatchHandler odataBatchHandler =
                new DefaultODataBatchHandler(new HttpServer(config));

            odataBatchHandler.MessageQuotas.MaxOperationsPerChangeset = 10;
            odataBatchHandler.MessageQuotas.MaxPartsPerBatch          = 10;

            config.MapODataServiceRoute("odata", "odata", builder.GetEdmModel(), odataBatchHandler);

            // Web API routes
        }
        public static void Register(HttpConfiguration config)
        {
            SecurityAdapterHelper.Enable(ReloadPermissionStrategy.CacheOnFirstAccess);

            var httpControllerRouteHandler = typeof(HttpControllerRouteHandler).GetField("_instance",
                                                                                         System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);

            if (httpControllerRouteHandler != null)
            {
                httpControllerRouteHandler.SetValue(null,
                                                    new Lazy <HttpControllerRouteHandler>(() => new SessionHttpControllerRouteHandler(), true));
            }

            if (HttpContext.Current != null)
            {
                ValueManager.ValueManagerType = typeof(MyASPSessionValueManager <>).GetGenericTypeDefinition();
            }

            config.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
            ODataModelBuilder modelBuilder = CreateODataModelBuilder();

            ODataBatchHandler batchHandler =
                new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer);

            config.MapODataServiceRoute(
                routeName: "ODataRoute",
                routePrefix: null,
                model: modelBuilder.GetEdmModel(),
                batchHandler: batchHandler);
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseRouting();
            app.UseODataBatching();

            // Newer endpoint routing.
            //app.UseEndpoints(endpoints =>
            //{
            //    endpoints.MapControllers();
            //    endpoints.Select().Filter().OrderBy().Count().MaxTop(10);
            //    endpoints.MapODataRoute("odata", "odata", GetEdmModel());
            //});

            // Older non-endpoint routing.
            var routeName          = "odata";
            var routePrefix        = "odata";
            var pathHandler        = new DefaultODataPathHandler();
            var batchHandler       = new DefaultODataBatchHandler();
            var routingConventions = GetRoutingConventions(app.ApplicationServices, routeName);

            app.UseMvc(routeBuilder =>
            {
                routeBuilder.EnableDependencyInjection();
                routeBuilder.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
                routeBuilder.MapODataServiceRoute(
                    routeName: routeName,
                    routePrefix: routePrefix,
                    model: GetEdmModel(),
                    pathHandler: pathHandler,
                    routingConventions: routingConventions,
                    batchHandler: batchHandler);
            });
        }
예제 #7
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var config = new HttpConfiguration
            {
                DependencyResolver = new UnityDependencyResolver(Bootstrapper.ConfigureUnity(new WebApplicationSettings()))
            };

            config.EnableCors(new EnableCorsAttribute("*", "*", "*"));

            config.MapHttpAttributeRoutes();

            config.SetupClrTypes();
            config.RegisterODataControllers();

            config.EnableSwagger(c =>
            {
                c.SingleApiVersion("v1", "NuClear River API reference");
                c.CustomProvider(defaultProvider => new ODataSwaggerProvider(defaultProvider, c, config));
            })
            .EnableSwaggerUi();


            var httpServer   = new HttpServer(config);
            var batchHandler = new DefaultODataBatchHandler(httpServer);

            config.MapODataServiceRoutes(batchHandler);

            appBuilder.UseWebApi(httpServer);
        }
예제 #8
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var configuration = new HttpConfiguration();
            var httpServer    = new HttpServer(configuration);

            // reporting api versions will return the headers "api-supported-versions" and "api-deprecated-versions"
            configuration.AddApiVersioning(o => o.ReportApiVersions = true);
            configuration.EnableCaseInsensitive(true);
            configuration.EnableUnqualifiedNameCall(true);

            var modelBuilder = new VersionedODataModelBuilder(configuration)
            {
                ModelBuilderFactory = () => new ODataConventionModelBuilder().EnableLowerCamelCase(),
                ModelConfigurations =
                {
                    new PersonModelConfiguration(),
                    new OrderModelConfiguration()
                }
            };
            var models       = modelBuilder.GetEdmModels();
            var batchHandler = new DefaultODataBatchHandler(httpServer);

            configuration.MapVersionedODataRoutes("odata", "api", models, batchHandler);
            configuration.MapVersionedODataRoutes("odata-bypath", "v{apiVersion}", models, batchHandler);
            appBuilder.UseWebApi(httpServer);
        }
예제 #9
0
        public void map_versioned_odata_routes_should_return_expected_result()
        {
            // arrange
            var configuration = new HttpConfiguration();
            var httpServer    = new HttpServer(configuration);
            var routeName     = "odata";
            var routePrefix   = "api/v3";
            var model         = new ODataModelBuilder().GetEdmModel();
            var apiVersion    = new ApiVersion(3, 0);
            var batchHandler  = new DefaultODataBatchHandler(httpServer);

            // act
            var route              = configuration.MapVersionedODataRoute(routeName, routePrefix, model, apiVersion, batchHandler);
            var constraint         = route.PathRouteConstraint;
            var routingConventions = GetRoutingConventions(configuration, route);
            var batchRoute         = configuration.Routes["odataBatch"];

            // assert
            routingConventions[0].Should().BeOfType <VersionedAttributeRoutingConvention>();
            routingConventions[1].Should().BeOfType <VersionedMetadataRoutingConvention>();
            routingConventions.OfType <MetadataRoutingConvention>().Should().BeEmpty();
            constraint.RouteName.Should().Be(routeName);
            route.RoutePrefix.Should().Be(routePrefix);
            batchRoute.Handler.Should().Be(batchHandler);
            batchRoute.RouteTemplate.Should().Be("api/v3/$batch");
        }
예제 #10
0
        public static void Register(HttpConfiguration config)
        {
            var batchHandler = new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer);

            config.MapODataServiceRoute("OrderODataRoute", ODataRoutePrefix + "/order", GetOrderEdmModal(), batchHandler);
            config.MapODataServiceRoute("ProductODataRoute", ODataRoutePrefix + "/product", GetProductEdmModal(), batchHandler);
        }
        public void map_versioned_odata_route_should_return_expected_result(string routePrefix)
        {
            // arrange
            var configuration = new HttpConfiguration();
            var httpServer    = new HttpServer(configuration);
            var routeName     = "odata";
            var batchTemplate = "$batch";
            var batchHandler  = new DefaultODataBatchHandler(httpServer);
            var models        = CreateModels(configuration);

            if (!string.IsNullOrEmpty(routePrefix))
            {
                batchTemplate = routePrefix + "/" + batchTemplate;
            }

            // act
            var route      = configuration.MapVersionedODataRoute(routeName, routePrefix, models, batchHandler);
            var batchRoute = configuration.Routes["odataBatch"];

            // assert
            var selector           = GetODataRootContainer(configuration, routeName).GetRequiredService <IEdmModelSelector>();
            var routingConventions = GetRoutingConventions(configuration, route);

            selector.ApiVersions.Should().Equal(new[] { new ApiVersion(1, 0), new ApiVersion(2, 0) });
            routingConventions[0].Should().BeOfType <VersionedAttributeRoutingConvention>();
            routingConventions[1].Should().BeOfType <VersionedMetadataRoutingConvention>();
            routingConventions.OfType <MetadataRoutingConvention>().Should().BeEmpty();
            route.PathRouteConstraint.RouteName.Should().Be(routeName);
            route.RoutePrefix.Should().Be(routePrefix);
            batchRoute.Handler.Should().Be(batchHandler);
            batchRoute.RouteTemplate.Should().Be(batchTemplate);
        }
예제 #12
0
        public async Task ProcessBatchAsync_CallsRegisterForDispose()
        {
            // Arrange
            List <IDisposable> expectedResourcesForDisposal = new List <IDisposable>();
            MockHttpServer     server = new MockHttpServer(request =>
            {
                var tmpContent = new StringContent(String.Empty);
                request.RegisterForDispose(tmpContent);
                expectedResourcesForDisposal.Add(tmpContent);
                return(new HttpResponseMessage {
                    Content = new StringContent(request.RequestUri.AbsoluteUri)
                });
            });
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(server);
            HttpRequestMessage       batchRequest = new HttpRequestMessage(HttpMethod.Post, "http://example.com/$batch")
            {
                Content = new MultipartContent("mixed")
                {
                    ODataBatchRequestHelper.CreateODataRequestContent(new HttpRequestMessage(HttpMethod.Get, "http://example.com/"))
                }
            };

            batchRequest.EnableHttpDependencyInjectionSupport();

            // Act
            var response = await batchHandler.ProcessBatchAsync(batchRequest, CancellationToken.None);

            var resourcesForDisposal = batchRequest.GetResourcesForDisposal();

            // Assert
            foreach (var expectedResource in expectedResourcesForDisposal)
            {
                Assert.Contains(expectedResource, resourcesForDisposal);
            }
        }
예제 #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseODataBatching();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints
                .Select().Filter().OrderBy().Count().Expand().MaxTop(50)
                .SetUrlKeyDelimiter(ODataUrlKeyDelimiter.Parentheses);

                var defaultBatchHandler = new DefaultODataBatchHandler();
                defaultBatchHandler.MessageQuotas.MaxNestingDepth           = 2;
                defaultBatchHandler.MessageQuotas.MaxOperationsPerChangeset = 10;

                endpoints.MapODataRoute("odata", "odata", GetEdmModel(), defaultBatchHandler);
            });
        }
예제 #14
0
        public void map_versioned_odata_route_should_return_expected_result()
        {
            // arrange
            var routeName          = "odata";
            var routePrefix        = "api/v3";
            var modelBuilder       = new ODataModelBuilder();
            var modelConfiguration = new TestModelConfiguration();
            var apiVersion         = new ApiVersion(3, 0);
            var batchHandler       = new DefaultODataBatchHandler();
            var app   = NewApplicationBuilder();
            var route = default(ODataRoute);

            modelConfiguration.Apply(modelBuilder, apiVersion);

            var model = modelBuilder.GetEdmModel();

            // act
            app.UseMvc(r => route = r.MapVersionedODataRoute(routeName, routePrefix, model, apiVersion, batchHandler));

            var perRequestContainer = app.ApplicationServices.GetRequiredService <IPerRouteContainer>();
            var serviceProvider     = perRequestContainer.GetODataRootContainer(route.Name);
            var routingConventions  = serviceProvider.GetRequiredService <IEnumerable <IODataRoutingConvention> >().ToArray();
            var constraint          = (VersionedODataPathRouteConstraint)route.PathRouteConstraint;

            // assert
            routingConventions[0].Should().BeOfType <VersionedAttributeRoutingConvention>();
            routingConventions[1].Should().BeOfType <VersionedMetadataRoutingConvention>();
            routingConventions.OfType <MetadataRoutingConvention>().Should().BeEmpty();
            constraint.RouteName.Should().Be(routeName);
            route.RoutePrefix.Should().Be(routePrefix);
            batchHandler.ODataRoute.Should().NotBeNull();
            batchHandler.ODataRouteName.Should().Be(routeName);
        }
예제 #15
0
 public async Task ProcessBatchAsync_Throws_IfRequestIsNull()
 {
     DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer());
     await ExceptionAssert.ThrowsArgumentNullAsync(
         () => batchHandler.ProcessBatchAsync(null, CancellationToken.None),
         "request");
 }
예제 #16
0
        public async Task ParseBatchRequestsAsync_Returns_RequestsFromMultipartContent()
        {
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer());
            HttpRequestMessage       batchRequest = new HttpRequestMessage(HttpMethod.Post, "http://example.com/$batch")
            {
                Content = new MultipartContent("mixed")
                {
                    ODataBatchRequestHelper.CreateODataRequestContent(new HttpRequestMessage(HttpMethod.Get, "http://example.com/")),
                    new MultipartContent("mixed") // ChangeSet
                    {
                        ODataBatchRequestHelper.CreateODataRequestContent(new HttpRequestMessage(HttpMethod.Post, "http://example.com/values"))
                    }
                }
            };

            batchRequest.EnableHttpDependencyInjectionSupport();

            IList <ODataBatchRequestItem> requests = await batchHandler.ParseBatchRequestsAsync(batchRequest, CancellationToken.None);

            Assert.Equal(2, requests.Count);

            var operationRequest = ((OperationRequestItem)requests[0]).Request;

            Assert.Equal(HttpMethod.Get, operationRequest.Method);
            Assert.Equal("http://example.com/", operationRequest.RequestUri.AbsoluteUri);

            var changeSetRequest = ((ChangeSetRequestItem)requests[1]).Requests.First();

            Assert.Equal(HttpMethod.Post, changeSetRequest.Method);
            Assert.Equal("http://example.com/values", changeSetRequest.RequestUri.AbsoluteUri);
        }
예제 #17
0
        public async Task ExecuteRequestMessagesAsync_DisposesResponseInCaseOfException()
        {
            List <MockHttpResponseMessage> responses = new List <MockHttpResponseMessage>();
            MockHttpServer server = new MockHttpServer(request =>
            {
                if (request.Method == HttpMethod.Put)
                {
                    throw new InvalidOperationException();
                }
                var response = new MockHttpResponseMessage();
                responses.Add(response);
                return(response);
            });
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(server);

            ODataBatchRequestItem[] requests = new ODataBatchRequestItem[]
            {
                new OperationRequestItem(new HttpRequestMessage(HttpMethod.Get, "http://example.com/")),
                new OperationRequestItem(new HttpRequestMessage(HttpMethod.Post, "http://example.com/")),
                new OperationRequestItem(new HttpRequestMessage(HttpMethod.Put, "http://example.com/")),
            };

            await ExceptionAssert.ThrowsAsync <InvalidOperationException>(
                () => batchHandler.ExecuteRequestMessagesAsync(requests, CancellationToken.None));

            Assert.Equal(2, responses.Count);
            foreach (var response in responses)
            {
                Assert.True(response.IsDisposed);
            }
        }
예제 #18
0
 public async Task ExecuteRequestMessagesAsync_Throws_IfRequestsIsNull()
 {
     DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer());
     await ExceptionAssert.ThrowsArgumentNullAsync(
         () => batchHandler.ExecuteRequestMessagesAsync(null, CancellationToken.None),
         "requests");
 }
예제 #19
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var configuration = new HttpConfiguration();
            var httpServer    = new HttpServer(configuration);

            // reporting api versions will return the headers "api-supported-versions" and "api-deprecated-versions"
            configuration.AddApiVersioning(options => options.ReportApiVersions = true);

            var modelBuilder = new VersionedODataModelBuilder(configuration)
            {
                ModelConfigurations =
                {
                    new PersonModelConfiguration(),
                    new OrderModelConfiguration()
                }
            };
            var models       = modelBuilder.GetEdmModels();
            var batchHandler = new DefaultODataBatchHandler(httpServer);

            // NOTE: you do NOT and should NOT use both the query string and url segment methods together.
            // this configuration is merely illustrating that they can coexist and allows you to easily
            // experiment with either configuration. one of these would be removed in a real application.
            configuration.MapVersionedODataRoutes("odata", "api", models, ConfigureContainer, batchHandler);
            configuration.MapVersionedODataRoutes("odata-bypath", "api/v{apiVersion}", models, ConfigureContainer);

            appBuilder.UseWebApi(httpServer);
        }
예제 #20
0
        public static void RegisterODataModel(HttpConfiguration config)
        {
            ODataBatchHandler odataBatchHandler = new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer);

            ODataModelBuilder builder = new ODataConventionModelBuilder();

            RegisterEntities(builder);
            RegisterFunctions(builder);
            RegisterActions(builder);


            var conventions = ODataRoutingConventions.CreateDefault();

            //conventions.Insert(0, new CityCustomConvention());

            config.MapODataServiceRoute(
                routeName: "ODataRoute",
                routePrefix: "odata",
                model: builder.GetEdmModel(),
                pathHandler: new DefaultODataPathHandler(),
                routingConventions: conventions,
                batchHandler: odataBatchHandler
                );
            config.MaxTop(null).OrderBy().Filter();
        }
예제 #21
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var configuration = new HttpConfiguration();
            var httpServer    = new HttpServer(configuration);

            configuration.AddApiVersioning(
                o =>
            {
                o.ReportApiVersions = true;
                o.AssumeDefaultVersionWhenUnspecified = true;
                o.ApiVersionReader = ApiVersionReader.Combine(
                    new QueryStringApiVersionReader(),
                    new HeaderApiVersionReader("api-version", "x-ms-version"));
            });

            var modelBuilder = new VersionedODataModelBuilder(configuration)
            {
                ModelBuilderFactory = () => new ODataConventionModelBuilder().EnableLowerCamelCase(),
                ModelConfigurations =
                {
                    new PersonModelConfiguration(),
                    new OrderModelConfiguration()
                }
            };
            var models       = modelBuilder.GetEdmModels();
            var batchHandler = new DefaultODataBatchHandler(httpServer);

            configuration.MapVersionedODataRoutes("odata", "api", models, OnConfigureContainer, batchHandler);
            configuration.Routes.MapHttpRoute("orders", "api/{controller}/{id}", new { id = Optional });
            appBuilder.UseWebApi(httpServer);
        }
예제 #22
0
 public async Task CreateResponseMessageAsync_Throws_IfRequestIsNull()
 {
     DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer());
     await ExceptionAssert.ThrowsArgumentNullAsync(
         () => batchHandler.CreateResponseMessageAsync(new ODataBatchResponseItem[0], null, CancellationToken.None),
         "request");
 }
        public async Task ExecuteRequestMessagesAsync_Throws_IfRequestsIsNull()
        {
            // Arrange
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler();

            // Act & Assert
            await ExceptionAssert.ThrowsArgumentNullAsync(() => batchHandler.ExecuteRequestMessagesAsync(null, null), "requests");
        }
        public async Task ProcessBatchAsync_Throws_IfContextIsNull()
        {
            // Arrange
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler();

            // Act & Assert
            await ExceptionAssert.ThrowsArgumentNullAsync(() => batchHandler.ProcessBatchAsync(null, null), "context");
        }
        public async Task CreateResponseMessageAsync_Throws_IfRequestIsNull()
        {
            // Arrange
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler();

            // Act & Assert
            await ExceptionAssert.ThrowsArgumentNullAsync(() => batchHandler.CreateResponseMessageAsync(new ODataBatchResponseItem[0], null), "request");
        }
        public async Task ParseBatchRequestsAsync_Throws_IfRequestIsNull()
        {
            // Arrange
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler();

            // Act & Assert
            await ExceptionAssert.ThrowsArgumentNullAsync(() => batchHandler.ParseBatchRequestsAsync(null), "context");
        }
        public void ValidateRequest_Throws_IfRequestIsNull()
        {
            // Arrange
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler();

            // Act & Assert
            ExceptionAssert.ThrowsArgumentNull(() => batchHandler.ValidateRequest(null), "request");
        }
예제 #28
0
        public void ValidateRequest_Throws_IfResponsesIsNull()
        {
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer());

            ExceptionAssert.ThrowsArgumentNull(
                () => batchHandler.ValidateRequest(null),
                "request");
        }
예제 #29
0
        public void Parameter_Constructor()
        {
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer());

            Assert.NotNull(batchHandler.Invoker);
            Assert.NotNull(batchHandler.MessageQuotas);
            Assert.Null(batchHandler.ODataRouteName);
        }
        public void ProcessBatchAsync_Throws_IfRequestIsNull()
        {
            DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer());

            Assert.ThrowsArgumentNull(
                () => batchHandler.ProcessBatchAsync(null, CancellationToken.None).Wait(),
                "request");
        }