< Summary

Class:Azure.ResourceManager.Compute.Models.DedicatedHost
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\DedicatedHost.cs
C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\DedicatedHost.Serialization.cs
Covered lines:123
Uncovered lines:38
Coverable lines:161
Total lines:352
Line coverage:76.3% (123 of 161)
Covered branches:75
Total branches:98
Branch coverage:76.5% (75 of 98)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-71.43%50%
.ctor(...)-100%100%
get_Sku()-100%100%
get_PlatformFaultDomain()-100%100%
get_AutoReplaceOnFailure()-100%100%
get_HostId()-100%100%
get_VirtualMachines()-100%100%
get_LicenseType()-100%100%
get_ProvisioningTime()-100%100%
get_ProvisioningState()-100%100%
get_InstanceView()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-52.83%53.57%
DeserializeDedicatedHost(...)-86.42%87.88%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\DedicatedHost.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> Specifies information about the Dedicated host. </summary>
 14    public partial class DedicatedHost : Resource
 15    {
 16        /// <summary> Initializes a new instance of DedicatedHost. </summary>
 17        /// <param name="location"> Resource location. </param>
 18        /// <param name="sku"> SKU of the dedicated host for Hardware Generation and VM family. Only name is required to
 419        public DedicatedHost(string location, Sku sku) : base(location)
 20        {
 421            if (location == null)
 22            {
 023                throw new ArgumentNullException(nameof(location));
 24            }
 425            if (sku == null)
 26            {
 027                throw new ArgumentNullException(nameof(sku));
 28            }
 29
 430            Sku = sku;
 431        }
 32
 33        /// <summary> Initializes a new instance of DedicatedHost. </summary>
 34        /// <param name="id"> Resource Id. </param>
 35        /// <param name="name"> Resource name. </param>
 36        /// <param name="type"> Resource type. </param>
 37        /// <param name="location"> Resource location. </param>
 38        /// <param name="tags"> Resource tags. </param>
 39        /// <param name="sku"> SKU of the dedicated host for Hardware Generation and VM family. Only name is required to
 40        /// <param name="platformFaultDomain"> Fault domain of the dedicated host within a dedicated host group. </param
 41        /// <param name="autoReplaceOnFailure"> Specifies whether the dedicated host should be replaced automatically in
 42        /// <param name="hostId"> A unique id generated and assigned to the dedicated host by the platform. &lt;br&gt;&l
 43        /// <param name="virtualMachines"> A list of references to all virtual machines in the Dedicated Host. </param>
 44        /// <param name="licenseType"> Specifies the software license type that will be applied to the VMs deployed on t
 45        /// <param name="provisioningTime"> The date when the host was first provisioned. </param>
 46        /// <param name="provisioningState"> The provisioning state, which only appears in the response. </param>
 47        /// <param name="instanceView"> The dedicated host instance view. </param>
 1248        internal DedicatedHost(string id, string name, string type, string location, IDictionary<string, string> tags, S
 49        {
 1250            Sku = sku;
 1251            PlatformFaultDomain = platformFaultDomain;
 1252            AutoReplaceOnFailure = autoReplaceOnFailure;
 1253            HostId = hostId;
 1254            VirtualMachines = virtualMachines;
 1255            LicenseType = licenseType;
 1256            ProvisioningTime = provisioningTime;
 1257            ProvisioningState = provisioningState;
 1258            InstanceView = instanceView;
 1259        }
 60
 61        /// <summary> SKU of the dedicated host for Hardware Generation and VM family. Only name is required to be set. 
 2462        public Sku Sku { get; set; }
 63        /// <summary> Fault domain of the dedicated host within a dedicated host group. </summary>
 2064        public int? PlatformFaultDomain { get; set; }
 65        /// <summary> Specifies whether the dedicated host should be replaced automatically in case of a failure. The va
 2066        public bool? AutoReplaceOnFailure { get; set; }
 67        /// <summary> A unique id generated and assigned to the dedicated host by the platform. &lt;br&gt;&lt;br&gt; Doe
 2468        public string HostId { get; }
 69        /// <summary> A list of references to all virtual machines in the Dedicated Host. </summary>
 3270        public IList<SubResourceReadOnly> VirtualMachines { get; }
 71        /// <summary> Specifies the software license type that will be applied to the VMs deployed on the dedicated host
 2072        public DedicatedHostLicenseTypes? LicenseType { get; set; }
 73        /// <summary> The date when the host was first provisioned. </summary>
 874        public DateTimeOffset? ProvisioningTime { get; }
 75        /// <summary> The provisioning state, which only appears in the response. </summary>
 876        public string ProvisioningState { get; }
 77        /// <summary> The dedicated host instance view. </summary>
 878        public DedicatedHostInstanceView InstanceView { get; }
 79    }
 80}

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\DedicatedHost.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;
 9using System.Collections.Generic;
 10using System.Text.Json;
 11using Azure.Core;
 12
 13namespace Azure.ResourceManager.Compute.Models
 14{
 15    public partial class DedicatedHost : IUtf8JsonSerializable
 16    {
 17        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 18        {
 819            writer.WriteStartObject();
 820            writer.WritePropertyName("sku");
 821            writer.WriteObjectValue(Sku);
 822            if (Id != null)
 23            {
 024                writer.WritePropertyName("id");
 025                writer.WriteStringValue(Id);
 26            }
 827            if (Name != null)
 28            {
 029                writer.WritePropertyName("name");
 030                writer.WriteStringValue(Name);
 31            }
 832            if (Type != null)
 33            {
 034                writer.WritePropertyName("type");
 035                writer.WriteStringValue(Type);
 36            }
 837            writer.WritePropertyName("location");
 838            writer.WriteStringValue(Location);
 839            if (Tags != null)
 40            {
 841                writer.WritePropertyName("tags");
 842                writer.WriteStartObject();
 3243                foreach (var item in Tags)
 44                {
 845                    writer.WritePropertyName(item.Key);
 846                    writer.WriteStringValue(item.Value);
 47                }
 848                writer.WriteEndObject();
 49            }
 850            writer.WritePropertyName("properties");
 851            writer.WriteStartObject();
 852            if (PlatformFaultDomain != null)
 53            {
 054                writer.WritePropertyName("platformFaultDomain");
 055                writer.WriteNumberValue(PlatformFaultDomain.Value);
 56            }
 857            if (AutoReplaceOnFailure != null)
 58            {
 059                writer.WritePropertyName("autoReplaceOnFailure");
 060                writer.WriteBooleanValue(AutoReplaceOnFailure.Value);
 61            }
 862            if (HostId != null)
 63            {
 064                writer.WritePropertyName("hostId");
 065                writer.WriteStringValue(HostId);
 66            }
 867            if (VirtualMachines != null)
 68            {
 069                writer.WritePropertyName("virtualMachines");
 070                writer.WriteStartArray();
 071                foreach (var item in VirtualMachines)
 72                {
 073                    writer.WriteObjectValue(item);
 74                }
 075                writer.WriteEndArray();
 76            }
 877            if (LicenseType != null)
 78            {
 079                writer.WritePropertyName("licenseType");
 080                writer.WriteStringValue(LicenseType.Value.ToSerialString());
 81            }
 882            if (ProvisioningTime != null)
 83            {
 084                writer.WritePropertyName("provisioningTime");
 085                writer.WriteStringValue(ProvisioningTime.Value, "O");
 86            }
 887            if (ProvisioningState != null)
 88            {
 089                writer.WritePropertyName("provisioningState");
 090                writer.WriteStringValue(ProvisioningState);
 91            }
 892            if (InstanceView != null)
 93            {
 094                writer.WritePropertyName("instanceView");
 095                writer.WriteObjectValue(InstanceView);
 96            }
 897            writer.WriteEndObject();
 898            writer.WriteEndObject();
 899        }
 100
 101        internal static DedicatedHost DeserializeDedicatedHost(JsonElement element)
 102        {
 12103            Sku sku = default;
 12104            string id = default;
 12105            string name = default;
 12106            string type = default;
 12107            string location = default;
 12108            IDictionary<string, string> tags = default;
 12109            int? platformFaultDomain = default;
 12110            bool? autoReplaceOnFailure = default;
 12111            string hostId = default;
 12112            IList<SubResourceReadOnly> virtualMachines = default;
 12113            DedicatedHostLicenseTypes? licenseType = default;
 12114            DateTimeOffset? provisioningTime = default;
 12115            string provisioningState = default;
 12116            DedicatedHostInstanceView instanceView = default;
 168117            foreach (var property in element.EnumerateObject())
 118            {
 72119                if (property.NameEquals("sku"))
 120                {
 12121                    sku = Sku.DeserializeSku(property.Value);
 12122                    continue;
 123                }
 60124                if (property.NameEquals("id"))
 125                {
 12126                    if (property.Value.ValueKind == JsonValueKind.Null)
 127                    {
 128                        continue;
 129                    }
 12130                    id = property.Value.GetString();
 12131                    continue;
 132                }
 48133                if (property.NameEquals("name"))
 134                {
 12135                    if (property.Value.ValueKind == JsonValueKind.Null)
 136                    {
 137                        continue;
 138                    }
 12139                    name = property.Value.GetString();
 12140                    continue;
 141                }
 36142                if (property.NameEquals("type"))
 143                {
 0144                    if (property.Value.ValueKind == JsonValueKind.Null)
 145                    {
 146                        continue;
 147                    }
 0148                    type = property.Value.GetString();
 0149                    continue;
 150                }
 36151                if (property.NameEquals("location"))
 152                {
 12153                    location = property.Value.GetString();
 12154                    continue;
 155                }
 24156                if (property.NameEquals("tags"))
 157                {
 12158                    if (property.Value.ValueKind == JsonValueKind.Null)
 159                    {
 160                        continue;
 161                    }
 12162                    Dictionary<string, string> dictionary = new Dictionary<string, string>();
 48163                    foreach (var property0 in property.Value.EnumerateObject())
 164                    {
 12165                        if (property0.Value.ValueKind == JsonValueKind.Null)
 166                        {
 0167                            dictionary.Add(property0.Name, null);
 168                        }
 169                        else
 170                        {
 12171                            dictionary.Add(property0.Name, property0.Value.GetString());
 172                        }
 173                    }
 12174                    tags = dictionary;
 12175                    continue;
 176                }
 12177                if (property.NameEquals("properties"))
 178                {
 176179                    foreach (var property0 in property.Value.EnumerateObject())
 180                    {
 76181                        if (property0.NameEquals("platformFaultDomain"))
 182                        {
 12183                            if (property0.Value.ValueKind == JsonValueKind.Null)
 184                            {
 185                                continue;
 186                            }
 12187                            platformFaultDomain = property0.Value.GetInt32();
 12188                            continue;
 189                        }
 64190                        if (property0.NameEquals("autoReplaceOnFailure"))
 191                        {
 12192                            if (property0.Value.ValueKind == JsonValueKind.Null)
 193                            {
 194                                continue;
 195                            }
 12196                            autoReplaceOnFailure = property0.Value.GetBoolean();
 12197                            continue;
 198                        }
 52199                        if (property0.NameEquals("hostId"))
 200                        {
 12201                            if (property0.Value.ValueKind == JsonValueKind.Null)
 202                            {
 203                                continue;
 204                            }
 12205                            hostId = property0.Value.GetString();
 12206                            continue;
 207                        }
 40208                        if (property0.NameEquals("virtualMachines"))
 209                        {
 12210                            if (property0.Value.ValueKind == JsonValueKind.Null)
 211                            {
 212                                continue;
 213                            }
 12214                            List<SubResourceReadOnly> array = new List<SubResourceReadOnly>();
 0215                            foreach (var item in property0.Value.EnumerateArray())
 216                            {
 0217                                if (item.ValueKind == JsonValueKind.Null)
 218                                {
 0219                                    array.Add(null);
 220                                }
 221                                else
 222                                {
 0223                                    array.Add(SubResourceReadOnly.DeserializeSubResourceReadOnly(item));
 224                                }
 225                            }
 12226                            virtualMachines = array;
 12227                            continue;
 228                        }
 28229                        if (property0.NameEquals("licenseType"))
 230                        {
 0231                            if (property0.Value.ValueKind == JsonValueKind.Null)
 232                            {
 233                                continue;
 234                            }
 0235                            licenseType = property0.Value.GetString().ToDedicatedHostLicenseTypes();
 0236                            continue;
 237                        }
 28238                        if (property0.NameEquals("provisioningTime"))
 239                        {
 12240                            if (property0.Value.ValueKind == JsonValueKind.Null)
 241                            {
 242                                continue;
 243                            }
 12244                            provisioningTime = property0.Value.GetDateTimeOffset("O");
 12245                            continue;
 246                        }
 16247                        if (property0.NameEquals("provisioningState"))
 248                        {
 12249                            if (property0.Value.ValueKind == JsonValueKind.Null)
 250                            {
 251                                continue;
 252                            }
 12253                            provisioningState = property0.Value.GetString();
 12254                            continue;
 255                        }
 4256                        if (property0.NameEquals("instanceView"))
 257                        {
 4258                            if (property0.Value.ValueKind == JsonValueKind.Null)
 259                            {
 260                                continue;
 261                            }
 4262                            instanceView = DedicatedHostInstanceView.DeserializeDedicatedHostInstanceView(property0.Valu
 263                            continue;
 264                        }
 265                    }
 266                    continue;
 267                }
 268            }
 12269            return new DedicatedHost(id, name, type, location, tags, sku, platformFaultDomain, autoReplaceOnFailure, hos
 270        }
 271    }
 272}