< Summary

Class:Azure.ResourceManager.Storage.Models.CorsRule
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\CorsRule.cs
C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\CorsRule.Serialization.cs
Covered lines:73
Uncovered lines:18
Coverable lines:91
Total lines:206
Line coverage:80.2% (73 of 91)
Covered branches:35
Total branches:50
Branch coverage:70% (35 of 50)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-100%50%
get_AllowedOrigins()-100%100%
get_AllowedMethods()-100%100%
get_MaxAgeInSeconds()-100%100%
get_ExposedHeaders()-100%100%
get_AllowedHeaders()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeCorsRule(...)-92.31%88.46%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\CorsRule.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Linq;
 11
 12namespace Azure.ResourceManager.Storage.Models
 13{
 14    /// <summary> Specifies a CORS rule for the Blob service. </summary>
 15    public partial class CorsRule
 16    {
 17        /// <summary> Initializes a new instance of CorsRule. </summary>
 18        /// <param name="allowedOrigins"> Required if CorsRule element is present. A list of origin domains that will be
 19        /// <param name="allowedMethods"> Required if CorsRule element is present. A list of HTTP methods that are allow
 20        /// <param name="maxAgeInSeconds"> Required if CorsRule element is present. The number of seconds that the clien
 21        /// <param name="exposedHeaders"> Required if CorsRule element is present. A list of response headers to expose 
 22        /// <param name="allowedHeaders"> Required if CorsRule element is present. A list of headers allowed to be part 
 023        public CorsRule(IEnumerable<string> allowedOrigins, IEnumerable<CorsRuleAllowedMethodsItem> allowedMethods, int 
 24        {
 025            if (allowedOrigins == null)
 26            {
 027                throw new ArgumentNullException(nameof(allowedOrigins));
 28            }
 029            if (allowedMethods == null)
 30            {
 031                throw new ArgumentNullException(nameof(allowedMethods));
 32            }
 033            if (exposedHeaders == null)
 34            {
 035                throw new ArgumentNullException(nameof(exposedHeaders));
 36            }
 037            if (allowedHeaders == null)
 38            {
 039                throw new ArgumentNullException(nameof(allowedHeaders));
 40            }
 41
 042            AllowedOrigins = allowedOrigins.ToList();
 043            AllowedMethods = allowedMethods.ToList();
 044            MaxAgeInSeconds = maxAgeInSeconds;
 045            ExposedHeaders = exposedHeaders.ToList();
 046            AllowedHeaders = allowedHeaders.ToList();
 047        }
 48
 49        /// <summary> Initializes a new instance of CorsRule. </summary>
 50        /// <param name="allowedOrigins"> Required if CorsRule element is present. A list of origin domains that will be
 51        /// <param name="allowedMethods"> Required if CorsRule element is present. A list of HTTP methods that are allow
 52        /// <param name="maxAgeInSeconds"> Required if CorsRule element is present. The number of seconds that the clien
 53        /// <param name="exposedHeaders"> Required if CorsRule element is present. A list of response headers to expose 
 54        /// <param name="allowedHeaders"> Required if CorsRule element is present. A list of headers allowed to be part 
 7255        internal CorsRule(IList<string> allowedOrigins, IList<CorsRuleAllowedMethodsItem> allowedMethods, int maxAgeInSe
 56        {
 7257            AllowedOrigins = allowedOrigins ?? new List<string>();
 7258            AllowedMethods = allowedMethods ?? new List<CorsRuleAllowedMethodsItem>();
 7259            MaxAgeInSeconds = maxAgeInSeconds;
 7260            ExposedHeaders = exposedHeaders ?? new List<string>();
 7261            AllowedHeaders = allowedHeaders ?? new List<string>();
 7262        }
 63
 64        /// <summary> Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, o
 12065        public IList<string> AllowedOrigins { get; }
 66        /// <summary> Required if CorsRule element is present. A list of HTTP methods that are allowed to be executed by
 12067        public IList<CorsRuleAllowedMethodsItem> AllowedMethods { get; }
 68        /// <summary> Required if CorsRule element is present. The number of seconds that the client/browser should cach
 19269        public int MaxAgeInSeconds { get; set; }
 70        /// <summary> Required if CorsRule element is present. A list of response headers to expose to CORS clients. </s
 12071        public IList<string> ExposedHeaders { get; }
 72        /// <summary> Required if CorsRule element is present. A list of headers allowed to be part of the cross-origin 
 12073        public IList<string> AllowedHeaders { get; }
 74    }
 75}

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\CorsRule.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.ResourceManager.Storage.Models
 13{
 14    public partial class CorsRule : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 2418            writer.WriteStartObject();
 2419            writer.WritePropertyName("allowedOrigins");
 2420            writer.WriteStartArray();
 12821            foreach (var item in AllowedOrigins)
 22            {
 4023                writer.WriteStringValue(item);
 24            }
 2425            writer.WriteEndArray();
 2426            writer.WritePropertyName("allowedMethods");
 2427            writer.WriteStartArray();
 20828            foreach (var item in AllowedMethods)
 29            {
 8030                writer.WriteStringValue(item.ToString());
 31            }
 2432            writer.WriteEndArray();
 2433            writer.WritePropertyName("maxAgeInSeconds");
 2434            writer.WriteNumberValue(MaxAgeInSeconds);
 2435            writer.WritePropertyName("exposedHeaders");
 2436            writer.WriteStartArray();
 12837            foreach (var item in ExposedHeaders)
 38            {
 4039                writer.WriteStringValue(item);
 40            }
 2441            writer.WriteEndArray();
 2442            writer.WritePropertyName("allowedHeaders");
 2443            writer.WriteStartArray();
 12844            foreach (var item in AllowedHeaders)
 45            {
 4046                writer.WriteStringValue(item);
 47            }
 2448            writer.WriteEndArray();
 2449            writer.WriteEndObject();
 2450        }
 51
 52        internal static CorsRule DeserializeCorsRule(JsonElement element)
 53        {
 4854            IList<string> allowedOrigins = default;
 4855            IList<CorsRuleAllowedMethodsItem> allowedMethods = default;
 4856            int maxAgeInSeconds = default;
 4857            IList<string> exposedHeaders = default;
 4858            IList<string> allowedHeaders = default;
 57659            foreach (var property in element.EnumerateObject())
 60            {
 24061                if (property.NameEquals("allowedOrigins"))
 62                {
 4863                    List<string> array = new List<string>();
 25664                    foreach (var item in property.Value.EnumerateArray())
 65                    {
 8066                        if (item.ValueKind == JsonValueKind.Null)
 67                        {
 068                            array.Add(null);
 69                        }
 70                        else
 71                        {
 8072                            array.Add(item.GetString());
 73                        }
 74                    }
 4875                    allowedOrigins = array;
 4876                    continue;
 77                }
 19278                if (property.NameEquals("allowedMethods"))
 79                {
 4880                    List<CorsRuleAllowedMethodsItem> array = new List<CorsRuleAllowedMethodsItem>();
 41681                    foreach (var item in property.Value.EnumerateArray())
 82                    {
 16083                        array.Add(new CorsRuleAllowedMethodsItem(item.GetString()));
 84                    }
 4885                    allowedMethods = array;
 4886                    continue;
 87                }
 14488                if (property.NameEquals("maxAgeInSeconds"))
 89                {
 4890                    maxAgeInSeconds = property.Value.GetInt32();
 4891                    continue;
 92                }
 9693                if (property.NameEquals("exposedHeaders"))
 94                {
 4895                    List<string> array = new List<string>();
 25696                    foreach (var item in property.Value.EnumerateArray())
 97                    {
 8098                        if (item.ValueKind == JsonValueKind.Null)
 99                        {
 0100                            array.Add(null);
 101                        }
 102                        else
 103                        {
 80104                            array.Add(item.GetString());
 105                        }
 106                    }
 48107                    exposedHeaders = array;
 48108                    continue;
 109                }
 48110                if (property.NameEquals("allowedHeaders"))
 111                {
 48112                    List<string> array = new List<string>();
 256113                    foreach (var item in property.Value.EnumerateArray())
 114                    {
 80115                        if (item.ValueKind == JsonValueKind.Null)
 116                        {
 0117                            array.Add(null);
 118                        }
 119                        else
 120                        {
 80121                            array.Add(item.GetString());
 122                        }
 123                    }
 48124                    allowedHeaders = array;
 125                    continue;
 126                }
 127            }
 48128            return new CorsRule(allowedOrigins, allowedMethods, maxAgeInSeconds, exposedHeaders, allowedHeaders);
 129        }
 130    }
 131}