< Summary

Class:Azure.ResourceManager.Storage.Models.ManagementPolicyRule
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ManagementPolicyRule.cs
C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ManagementPolicyRule.Serialization.cs
Covered lines:47
Uncovered lines:2
Coverable lines:49
Total lines:124
Line coverage:95.9% (47 of 49)
Covered branches:16
Total branches:18
Branch coverage:88.8% (16 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-77.78%50%
.ctor(...)-100%100%
get_Enabled()-100%100%
get_Name()-100%100%
get_Type()-100%100%
get_Definition()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeManagementPolicyRule(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ManagementPolicyRule.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;
 9
 10namespace Azure.ResourceManager.Storage.Models
 11{
 12    /// <summary> An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. </summary>
 13    public partial class ManagementPolicyRule
 14    {
 15        /// <summary> Initializes a new instance of ManagementPolicyRule. </summary>
 16        /// <param name="name"> A rule name can contain any combination of alpha numeric characters. Rule name is case-s
 17        /// <param name="definition"> An object that defines the Lifecycle rule. </param>
 1218        public ManagementPolicyRule(string name, ManagementPolicyDefinition definition)
 19        {
 1220            if (name == null)
 21            {
 022                throw new ArgumentNullException(nameof(name));
 23            }
 1224            if (definition == null)
 25            {
 026                throw new ArgumentNullException(nameof(definition));
 27            }
 28
 1229            Name = name;
 1230            Type = "Lifecycle";
 1231            Definition = definition;
 1232        }
 33
 34        /// <summary> Initializes a new instance of ManagementPolicyRule. </summary>
 35        /// <param name="enabled"> Rule is enabled if set to true. </param>
 36        /// <param name="name"> A rule name can contain any combination of alpha numeric characters. Rule name is case-s
 37        /// <param name="type"> The valid value is Lifecycle. </param>
 38        /// <param name="definition"> An object that defines the Lifecycle rule. </param>
 2439        internal ManagementPolicyRule(bool? enabled, string name, string type, ManagementPolicyDefinition definition)
 40        {
 2441            Enabled = enabled;
 2442            Name = name;
 2443            Type = type;
 2444            Definition = definition;
 2445        }
 46
 47        /// <summary> Rule is enabled if set to true. </summary>
 11648        public bool? Enabled { get; set; }
 49        /// <summary> A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. 
 16850        public string Name { get; set; }
 51        /// <summary> The valid value is Lifecycle. </summary>
 4852        public string Type { get; set; }
 53        /// <summary> An object that defines the Lifecycle rule. </summary>
 36054        public ManagementPolicyDefinition Definition { get; set; }
 55    }
 56}

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ManagementPolicyRule.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.Text.Json;
 9using Azure.Core;
 10
 11namespace Azure.ResourceManager.Storage.Models
 12{
 13    public partial class ManagementPolicyRule : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 1217            writer.WriteStartObject();
 1218            if (Enabled != null)
 19            {
 820                writer.WritePropertyName("enabled");
 821                writer.WriteBooleanValue(Enabled.Value);
 22            }
 1223            writer.WritePropertyName("name");
 1224            writer.WriteStringValue(Name);
 1225            writer.WritePropertyName("type");
 1226            writer.WriteStringValue(Type);
 1227            writer.WritePropertyName("definition");
 1228            writer.WriteObjectValue(Definition);
 1229            writer.WriteEndObject();
 1230        }
 31
 32        internal static ManagementPolicyRule DeserializeManagementPolicyRule(JsonElement element)
 33        {
 2434            bool? enabled = default;
 2435            string name = default;
 2436            string type = default;
 2437            ManagementPolicyDefinition definition = default;
 24038            foreach (var property in element.EnumerateObject())
 39            {
 9640                if (property.NameEquals("enabled"))
 41                {
 2442                    if (property.Value.ValueKind == JsonValueKind.Null)
 43                    {
 44                        continue;
 45                    }
 2446                    enabled = property.Value.GetBoolean();
 2447                    continue;
 48                }
 7249                if (property.NameEquals("name"))
 50                {
 2451                    name = property.Value.GetString();
 2452                    continue;
 53                }
 4854                if (property.NameEquals("type"))
 55                {
 2456                    type = property.Value.GetString();
 2457                    continue;
 58                }
 2459                if (property.NameEquals("definition"))
 60                {
 2461                    definition = ManagementPolicyDefinition.DeserializeManagementPolicyDefinition(property.Value);
 62                    continue;
 63                }
 64            }
 2465            return new ManagementPolicyRule(enabled, name, type, definition);
 66        }
 67    }
 68}