Пример #1
0
        public void BindParameter_GuardClauses()
        {
            HttpConfiguration config = new HttpConfiguration();
            Type         type        = typeof(TestParameter);
            IModelBinder binder      = new Mock <IModelBinder>().Object;

            Assert.ThrowsArgumentNull(() => HttpConfigurationExtensions.BindParameter(null, type, binder), "configuration");
            Assert.ThrowsArgumentNull(() => HttpConfigurationExtensions.BindParameter(config, null, binder), "type");
            Assert.ThrowsArgumentNull(() => HttpConfigurationExtensions.BindParameter(config, type, null), "binder");
        }
 public void SuppressHostPrincipal_Throws_WhenConfigurationIsNull()
 {
     // Act & Assert
     Assert.ThrowsArgumentNull(
         () =>
     {
         HttpConfigurationExtensions.SuppressHostPrincipal(null);
     },
         "configuration"
         );
 }
Пример #3
0
        public static void Register(HttpConfiguration config)
        {
            EnableCorsAttribute enableCorsAttribute = new EnableCorsAttribute("*", "*", "*");

            CorsHttpConfigurationExtensions.EnableCors(config, (ICorsPolicyProvider)enableCorsAttribute);
            HttpConfigurationExtensions.MapHttpAttributeRoutes(config);
            config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", (object)new
            {
                id = RouteParameter.Optional
            });
        }
        public void RegisterHttpRequestMessageThrowsGivenNullConfig()
        {
            var exception = Assert.Throws <ArgumentNullException>(() => HttpConfigurationExtensions.RegisterHttpRequestMessage(null));

            Assert.Equal("config", exception.ParamName);
        }