public void AuthenticationType_ReturnsSpecifiedInstance()
        {
            // Arrange
            string expectedAuthenticationType = "AuthenticationType";
            HostAuthenticationFilter filter   = CreateProductUnderTest(expectedAuthenticationType);

            // Act
            string authenticationType = filter.AuthenticationType;

            // Assert
            Assert.Same(expectedAuthenticationType, authenticationType);
        }
        public void InnerFilter_IsHostAuthenticationFilter_WhenUsingConstructorWithString()
        {
            // Arrange
            string expectedAuthenticationType   = "Ignore";
            HostAuthenticationAttribute product = CreateProductUnderTest(expectedAuthenticationType);

            // Act
            IAuthenticationFilter innerFilter = product.InnerFilter;

            // Assert
            HostAuthenticationFilter typedInnerFilter = Assert.IsType <HostAuthenticationFilter>(innerFilter);

            Assert.Same(expectedAuthenticationType, typedInnerFilter.AuthenticationType);
        }
        public static void Register(HttpConfiguration config)
        {
            // FORMATADORES JSON
            config.Formatters.JsonFormatter.SerializerSettings.Culture    = CultureInfo.GetCultureInfo("pt-BR");
            config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
            config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new IsoDateTimeConverter());
            config.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

            // IGNORA REFERENCIA CIRCULAR
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

            // Web API configuration and services
            config.Services.Replace(typeof(IExceptionLogger), new UnhandledExceptionLogger());
            config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler());

            // Serviços e configuração da API da Web
            config.SuppressDefaultHostAuthentication();

            // Rotas da API da Web
            //config.MapHttpAttributeRoutes();

            var hostAuthenticationFilter = new HostAuthenticationFilter(OAuthDefaults.AuthenticationType);

            config.Filters.Add(hostAuthenticationFilter);
            // config.Filters.Add(new HostAuthenticationFilter("Bearer"));


            // Serviços e configuração da API da Web

            // Rotas da API da Web
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }