< Summary

Class:Azure.ResourceManager.Storage.Models.LegalHold
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\LegalHold.cs
C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\LegalHold.Serialization.cs
Covered lines:33
Uncovered lines:4
Coverable lines:37
Total lines:113
Line coverage:89.1% (33 of 37)
Covered branches:16
Total branches:20
Branch coverage:80% (16 of 20)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
.ctor(...)-100%50%
get_HasLegalHold()-100%100%
get_Tags()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-81.82%75%
DeserializeLegalHold(...)-93.33%91.67%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\LegalHold.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> The LegalHold property of a blob container. </summary>
 15    public partial class LegalHold
 16    {
 17        /// <summary> Initializes a new instance of LegalHold. </summary>
 18        /// <param name="tags"> Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case at SR
 819        public LegalHold(IEnumerable<string> tags)
 20        {
 821            if (tags == null)
 22            {
 023                throw new ArgumentNullException(nameof(tags));
 24            }
 25
 826            Tags = tags.ToList();
 827        }
 28
 29        /// <summary> Initializes a new instance of LegalHold. </summary>
 30        /// <param name="hasLegalHold"> The hasLegalHold public property is set to true by SRP if there are at least one
 31        /// <param name="tags"> Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case at SR
 1632        internal LegalHold(bool? hasLegalHold, IList<string> tags)
 33        {
 1634            HasLegalHold = hasLegalHold;
 1635            Tags = tags ?? new List<string>();
 1636        }
 37
 38        /// <summary> The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The
 3239        public bool? HasLegalHold { get; }
 40        /// <summary> Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case at SRP. </summa
 2841        public IList<string> Tags { get; }
 42    }
 43}

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\LegalHold.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 LegalHold : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 1618            writer.WriteStartObject();
 1619            if (HasLegalHold != null)
 20            {
 021                writer.WritePropertyName("hasLegalHold");
 022                writer.WriteBooleanValue(HasLegalHold.Value);
 23            }
 1624            writer.WritePropertyName("tags");
 1625            writer.WriteStartArray();
 12826            foreach (var item in Tags)
 27            {
 4828                writer.WriteStringValue(item);
 29            }
 1630            writer.WriteEndArray();
 1631            writer.WriteEndObject();
 1632        }
 33
 34        internal static LegalHold DeserializeLegalHold(JsonElement element)
 35        {
 1636            bool? hasLegalHold = default;
 1637            IList<string> tags = default;
 9638            foreach (var property in element.EnumerateObject())
 39            {
 3240                if (property.NameEquals("hasLegalHold"))
 41                {
 1642                    if (property.Value.ValueKind == JsonValueKind.Null)
 43                    {
 44                        continue;
 45                    }
 1646                    hasLegalHold = property.Value.GetBoolean();
 1647                    continue;
 48                }
 1649                if (property.NameEquals("tags"))
 50                {
 1651                    List<string> array = new List<string>();
 8052                    foreach (var item in property.Value.EnumerateArray())
 53                    {
 2454                        if (item.ValueKind == JsonValueKind.Null)
 55                        {
 056                            array.Add(null);
 57                        }
 58                        else
 59                        {
 2460                            array.Add(item.GetString());
 61                        }
 62                    }
 1663                    tags = array;
 64                    continue;
 65                }
 66            }
 1667            return new LegalHold(hasLegalHold, tags);
 68        }
 69    }
 70}