public async Task InitializeOrigins_SetsCacheToNull_IfEnabledGloballyWithoutOrigins()
        {
            // Arrange
            HttpConfiguration corsConfig = new HttpConfiguration();

            corsConfig.EnableCors();
            HttpRequestMessage request = new HttpRequestMessage();

            request.SetConfiguration(corsConfig);

            // Act
            IEnumerable <string> actual = await CrossDomainController.InitializeOrigins(corsConfig, request);

            // Assert
            //Assert.Equal(origins, actual);
        }
        public async Task InitializeOrigins_CheckValues_IfEnabledGlobally(IEnumerable <string> origins)
        {
            // Arrange
            HttpConfiguration corsConfig = new HttpConfiguration();

            corsConfig.EnableCors(new EnableCorsAttribute(string.Join(",", origins), "*", "*"));
            HttpRequestMessage request = new HttpRequestMessage();

            request.SetConfiguration(corsConfig);

            // Act
            IEnumerable <string> actual = await CrossDomainController.InitializeOrigins(corsConfig, request);

            // Assert
            Assert.Equal(origins, actual);
        }
        public async Task InitializeOrigins_ReturnsCachedList()
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            config.EnableCors(new EnableCorsAttribute("http://test", "*", "*"));
            HttpRequestMessage request = new HttpRequestMessage();

            request.SetConfiguration(config);

            // Act
            IEnumerable <string> actual1 = await CrossDomainController.InitializeOrigins(config, new HttpRequestMessage());

            IEnumerable <string> actual2 = await CrossDomainController.InitializeOrigins(config, new HttpRequestMessage());

            // Assert
            Assert.Same(actual1, actual2);
        }
        public async Task InitializeOrigins_CheckValues_IfPassedDirectly(IEnumerable <string> origins)
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            new MobileAppConfiguration()
            .MapLegacyCrossDomainController(origins)
            .ApplyTo(config);

            HttpRequestMessage request = new HttpRequestMessage();

            request.SetConfiguration(config);

            // Act
            IEnumerable <string> actual = await CrossDomainController.InitializeOrigins(config, request);

            // Assert
            Assert.Equal(origins, actual);
        }
        public async Task OriginsCache_Null_IfNoOriginsSet()
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            new MobileAppConfiguration()
            .MapLegacyCrossDomainController()
            .ApplyTo(config);

            HttpRequestMessage request = new HttpRequestMessage();

            request.SetConfiguration(config);

            // Act
            IEnumerable <string> actual = await CrossDomainController.InitializeOrigins(config, request);

            // Assert
            Assert.NotNull(actual);
            Assert.Empty(actual);
        }
        public async Task DirectOrigins_Wins_IfGlobalAlsoSet()
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            new MobileAppConfiguration()
            .MapLegacyCrossDomainController(this.allowedOrigins)
            .ApplyTo(config);

            config.EnableCors(new EnableCorsAttribute("http://notused", "*", "*"));

            HttpRequestMessage request = new HttpRequestMessage();

            request.SetConfiguration(config);

            // Act
            IEnumerable <string> actual = await CrossDomainController.InitializeOrigins(config, request);

            // Assert
            Assert.Equal(this.allowedOrigins, actual);
        }