< Summary

Class:Azure.ResourceManager.Compute.Models.VirtualMachineImage
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\VirtualMachineImage.cs
C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\VirtualMachineImage.Serialization.cs
Covered lines:54
Uncovered lines:58
Coverable lines:112
Total lines:257
Line coverage:48.2% (54 of 112)
Covered branches:37
Total branches:68
Branch coverage:54.4% (37 of 68)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-100%100%
get_Plan()-100%100%
get_OsDiskImage()-100%100%
get_DataDiskImages()-0%100%
get_AutomaticOSUpgradeProperties()-100%100%
get_HyperVGeneration()-0%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-0%0%
DeserializeVirtualMachineImage(...)-78.57%80.43%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\VirtualMachineImage.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;
 10
 11namespace Azure.ResourceManager.Compute.Models
 12{
 13    /// <summary> Describes a Virtual Machine Image. </summary>
 14    public partial class VirtualMachineImage : VirtualMachineImageResource
 15    {
 16        /// <summary> Initializes a new instance of VirtualMachineImage. </summary>
 17        /// <param name="name"> The name of the resource. </param>
 18        /// <param name="location"> The supported Azure location of the resource. </param>
 019        public VirtualMachineImage(string name, string location) : base(name, location)
 20        {
 021            if (name == null)
 22            {
 023                throw new ArgumentNullException(nameof(name));
 24            }
 025            if (location == null)
 26            {
 027                throw new ArgumentNullException(nameof(location));
 28            }
 029        }
 30
 31        /// <summary> Initializes a new instance of VirtualMachineImage. </summary>
 32        /// <param name="id"> Resource Id. </param>
 33        /// <param name="name"> The name of the resource. </param>
 34        /// <param name="location"> The supported Azure location of the resource. </param>
 35        /// <param name="tags"> Specifies the tags that are assigned to the virtual machine. For more information about 
 36        /// <param name="plan"> Used for establishing the purchase context of any 3rd Party artifact through MarketPlace
 37        /// <param name="osDiskImage"> Contains the os disk image information. </param>
 38        /// <param name="dataDiskImages"> The list of data disk images information. </param>
 39        /// <param name="automaticOSUpgradeProperties"> Describes automatic OS upgrade properties on the image. </param>
 40        /// <param name="hyperVGeneration"> Specifies the HyperVGeneration Type. </param>
 3241        internal VirtualMachineImage(string id, string name, string location, IDictionary<string, string> tags, Purchase
 42        {
 3243            Plan = plan;
 3244            OsDiskImage = osDiskImage;
 3245            DataDiskImages = dataDiskImages;
 3246            AutomaticOSUpgradeProperties = automaticOSUpgradeProperties;
 3247            HyperVGeneration = hyperVGeneration;
 3248        }
 49
 50        /// <summary> Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. </summar
 5651        public PurchasePlan Plan { get; set; }
 52        /// <summary> Contains the os disk image information. </summary>
 3653        public OSDiskImage OsDiskImage { get; set; }
 54        /// <summary> The list of data disk images information. </summary>
 055        public IList<DataDiskImage> DataDiskImages { get; set; }
 56        /// <summary> Describes automatic OS upgrade properties on the image. </summary>
 4857        public AutomaticOSUpgradeProperties AutomaticOSUpgradeProperties { get; set; }
 58        /// <summary> Specifies the HyperVGeneration Type. </summary>
 059        public HyperVGenerationTypes? HyperVGeneration { get; set; }
 60    }
 61}

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\VirtualMachineImage.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.Compute.Models
 13{
 14    public partial class VirtualMachineImage : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 018            writer.WriteStartObject();
 019            writer.WritePropertyName("name");
 020            writer.WriteStringValue(Name);
 021            writer.WritePropertyName("location");
 022            writer.WriteStringValue(Location);
 023            if (Tags != null)
 24            {
 025                writer.WritePropertyName("tags");
 026                writer.WriteStartObject();
 027                foreach (var item in Tags)
 28                {
 029                    writer.WritePropertyName(item.Key);
 030                    writer.WriteStringValue(item.Value);
 31                }
 032                writer.WriteEndObject();
 33            }
 034            if (Id != null)
 35            {
 036                writer.WritePropertyName("id");
 037                writer.WriteStringValue(Id);
 38            }
 039            writer.WritePropertyName("properties");
 040            writer.WriteStartObject();
 041            if (Plan != null)
 42            {
 043                writer.WritePropertyName("plan");
 044                writer.WriteObjectValue(Plan);
 45            }
 046            if (OsDiskImage != null)
 47            {
 048                writer.WritePropertyName("osDiskImage");
 049                writer.WriteObjectValue(OsDiskImage);
 50            }
 051            if (DataDiskImages != null)
 52            {
 053                writer.WritePropertyName("dataDiskImages");
 054                writer.WriteStartArray();
 055                foreach (var item in DataDiskImages)
 56                {
 057                    writer.WriteObjectValue(item);
 58                }
 059                writer.WriteEndArray();
 60            }
 061            if (AutomaticOSUpgradeProperties != null)
 62            {
 063                writer.WritePropertyName("automaticOSUpgradeProperties");
 064                writer.WriteObjectValue(AutomaticOSUpgradeProperties);
 65            }
 066            if (HyperVGeneration != null)
 67            {
 068                writer.WritePropertyName("hyperVGeneration");
 069                writer.WriteStringValue(HyperVGeneration.Value.ToString());
 70            }
 071            writer.WriteEndObject();
 072            writer.WriteEndObject();
 073        }
 74
 75        internal static VirtualMachineImage DeserializeVirtualMachineImage(JsonElement element)
 76        {
 3277            string name = default;
 3278            string location = default;
 3279            IDictionary<string, string> tags = default;
 3280            string id = default;
 3281            PurchasePlan plan = default;
 3282            OSDiskImage osDiskImage = default;
 3283            IList<DataDiskImage> dataDiskImages = default;
 3284            AutomaticOSUpgradeProperties automaticOSUpgradeProperties = default;
 3285            HyperVGenerationTypes? hyperVGeneration = default;
 32086            foreach (var property in element.EnumerateObject())
 87            {
 12888                if (property.NameEquals("name"))
 89                {
 3290                    name = property.Value.GetString();
 3291                    continue;
 92                }
 9693                if (property.NameEquals("location"))
 94                {
 3295                    location = property.Value.GetString();
 3296                    continue;
 97                }
 6498                if (property.NameEquals("tags"))
 99                {
 0100                    if (property.Value.ValueKind == JsonValueKind.Null)
 101                    {
 102                        continue;
 103                    }
 0104                    Dictionary<string, string> dictionary = new Dictionary<string, string>();
 0105                    foreach (var property0 in property.Value.EnumerateObject())
 106                    {
 0107                        if (property0.Value.ValueKind == JsonValueKind.Null)
 108                        {
 0109                            dictionary.Add(property0.Name, null);
 110                        }
 111                        else
 112                        {
 0113                            dictionary.Add(property0.Name, property0.Value.GetString());
 114                        }
 115                    }
 0116                    tags = dictionary;
 0117                    continue;
 118                }
 64119                if (property.NameEquals("id"))
 120                {
 32121                    if (property.Value.ValueKind == JsonValueKind.Null)
 122                    {
 123                        continue;
 124                    }
 32125                    id = property.Value.GetString();
 32126                    continue;
 127                }
 32128                if (property.NameEquals("properties"))
 129                {
 400130                    foreach (var property0 in property.Value.EnumerateObject())
 131                    {
 168132                        if (property0.NameEquals("plan"))
 133                        {
 8134                            if (property0.Value.ValueKind == JsonValueKind.Null)
 135                            {
 136                                continue;
 137                            }
 8138                            plan = PurchasePlan.DeserializePurchasePlan(property0.Value);
 8139                            continue;
 140                        }
 160141                        if (property0.NameEquals("osDiskImage"))
 142                        {
 32143                            if (property0.Value.ValueKind == JsonValueKind.Null)
 144                            {
 145                                continue;
 146                            }
 32147                            osDiskImage = OSDiskImage.DeserializeOSDiskImage(property0.Value);
 32148                            continue;
 149                        }
 128150                        if (property0.NameEquals("dataDiskImages"))
 151                        {
 32152                            if (property0.Value.ValueKind == JsonValueKind.Null)
 153                            {
 154                                continue;
 155                            }
 32156                            List<DataDiskImage> array = new List<DataDiskImage>();
 0157                            foreach (var item in property0.Value.EnumerateArray())
 158                            {
 0159                                if (item.ValueKind == JsonValueKind.Null)
 160                                {
 0161                                    array.Add(null);
 162                                }
 163                                else
 164                                {
 0165                                    array.Add(DataDiskImage.DeserializeDataDiskImage(item));
 166                                }
 167                            }
 32168                            dataDiskImages = array;
 32169                            continue;
 170                        }
 96171                        if (property0.NameEquals("automaticOSUpgradeProperties"))
 172                        {
 32173                            if (property0.Value.ValueKind == JsonValueKind.Null)
 174                            {
 175                                continue;
 176                            }
 32177                            automaticOSUpgradeProperties = AutomaticOSUpgradeProperties.DeserializeAutomaticOSUpgradePro
 32178                            continue;
 179                        }
 64180                        if (property0.NameEquals("hyperVGeneration"))
 181                        {
 16182                            if (property0.Value.ValueKind == JsonValueKind.Null)
 183                            {
 184                                continue;
 185                            }
 16186                            hyperVGeneration = new HyperVGenerationTypes(property0.Value.GetString());
 187                            continue;
 188                        }
 189                    }
 190                    continue;
 191                }
 192            }
 32193            return new VirtualMachineImage(id, name, location, tags, plan, osDiskImage, dataDiskImages, automaticOSUpgra
 194        }
 195    }
 196}