コード例 #1
0
ファイル: CorsPolicyTests.cs プロジェクト: kouweizhong/CORS
        public void ToString_ReturnsThePropertyValues()
        {
            // Arrange
            var corsPolicy = new CorsPolicy
            {
                PreflightMaxAge     = TimeSpan.FromSeconds(12),
                SupportsCredentials = true
            };

            corsPolicy.Headers.Add("foo");
            corsPolicy.Headers.Add("bar");
            corsPolicy.Origins.Add("http://example.com");
            corsPolicy.Origins.Add("http://example.org");
            corsPolicy.Methods.Add("GET");

            // Act
            var policyString = corsPolicy.ToString();

            // Assert
            Assert.Equal(
                @"AllowAnyHeader: False, AllowAnyMethod: False, AllowAnyOrigin: False, PreflightMaxAge: 12," +
                " SupportsCredentials: True, Origins: {http://example.com,http://example.org}, Methods: {GET}," +
                " Headers: {foo,bar}, ExposedHeaders: {}",
                policyString);
        }
コード例 #2
0
        public void ToString_ReturnsThePropertyValues()
        {
            CorsPolicy corsPolicy = new CorsPolicy
            {
                AllowAnyHeader = true,
                AllowAnyOrigin = true,
                PreflightMaxAge = 10,
                SupportsCredentials = true
            };
            corsPolicy.Headers.Add("foo");
            corsPolicy.Headers.Add("bar");
            corsPolicy.Origins.Add("http://example.com");
            corsPolicy.Origins.Add("http://example.org");
            corsPolicy.Methods.Add("GET");

            Assert.Equal(@"AllowAnyHeader: True, AllowAnyMethod: False, AllowAnyOrigin: True, PreflightMaxAge: 10, SupportsCredentials: True, Origins: {http://example.com,http://example.org}, Methods: {GET}, Headers: {foo,bar}, ExposedHeaders: {}", corsPolicy.ToString());
        }
コード例 #3
0
        public void ToString_ReturnsThePropertyValues()
        {
            CorsPolicy corsPolicy = new CorsPolicy
            {
                AllowAnyHeader      = true,
                AllowAnyOrigin      = true,
                PreflightMaxAge     = 10,
                SupportsCredentials = true
            };

            corsPolicy.Headers.Add("foo");
            corsPolicy.Headers.Add("bar");
            corsPolicy.Origins.Add("http://example.com");
            corsPolicy.Origins.Add("http://example.org");
            corsPolicy.Methods.Add("GET");

            Assert.Equal(
                @"AllowAnyHeader: True, AllowAnyMethod: False, AllowAnyOrigin: True, PreflightMaxAge: 10, SupportsCredentials: True, Origins: {http://example.com,http://example.org}, Methods: {GET}, Headers: {foo,bar}, ExposedHeaders: {}",
                corsPolicy.ToString()
                );
        }
コード例 #4
0
ファイル: CorsPolicyTests.cs プロジェクト: qiudesong/CORS
        public void ToString_ReturnsThePropertyValues()
        {
            // Arrange
            var corsPolicy = new CorsPolicy
            {
                PreflightMaxAge = TimeSpan.FromSeconds(12),
                SupportsCredentials = true
            };
            corsPolicy.Headers.Add("foo");
            corsPolicy.Headers.Add("bar");
            corsPolicy.Origins.Add("http://example.com");
            corsPolicy.Origins.Add("http://example.org");
            corsPolicy.Methods.Add("GET");

            // Act
            var policyString = corsPolicy.ToString();

            // Assert
            Assert.Equal(
                @"AllowAnyHeader: False, AllowAnyMethod: False, AllowAnyOrigin: False, PreflightMaxAge: 12,"+
                " SupportsCredentials: True, Origins: {http://example.com,http://example.org}, Methods: {GET},"+
                " Headers: {foo,bar}, ExposedHeaders: {}",
                policyString);
        }