< Summary

Class:Azure.ResourceManager.Compute.Models.RunCommandDocument
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\RunCommandDocument.cs
C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\RunCommandDocument.Serialization.cs
Covered lines:48
Uncovered lines:19
Coverable lines:67
Total lines:180
Line coverage:71.6% (48 of 67)
Covered branches:29
Total branches:46
Branch coverage:63% (29 of 46)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-66.67%50%
get_Script()-100%100%
get_Parameters()-100%100%
DeserializeRunCommandDocument(...)-95%92.31%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\RunCommandDocument.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.Compute.Models
 13{
 14    /// <summary> Describes the properties of a Run Command. </summary>
 15    public partial class RunCommandDocument : RunCommandDocumentBase
 16    {
 17        /// <summary> Initializes a new instance of RunCommandDocument. </summary>
 18        /// <param name="schema"> The VM run command schema. </param>
 19        /// <param name="id"> The VM run command id. </param>
 20        /// <param name="osType"> The Operating System type. </param>
 21        /// <param name="label"> The VM run command label. </param>
 22        /// <param name="description"> The VM run command description. </param>
 23        /// <param name="script"> The script to be executed. </param>
 024        internal RunCommandDocument(string schema, string id, OperatingSystemTypes osType, string label, string descript
 25        {
 026            if (schema == null)
 27            {
 028                throw new ArgumentNullException(nameof(schema));
 29            }
 030            if (id == null)
 31            {
 032                throw new ArgumentNullException(nameof(id));
 33            }
 034            if (label == null)
 35            {
 036                throw new ArgumentNullException(nameof(label));
 37            }
 038            if (description == null)
 39            {
 040                throw new ArgumentNullException(nameof(description));
 41            }
 042            if (script == null)
 43            {
 044                throw new ArgumentNullException(nameof(script));
 45            }
 46
 047            Script = script.ToArray();
 048        }
 49
 50        /// <summary> Initializes a new instance of RunCommandDocument. </summary>
 51        /// <param name="schema"> The VM run command schema. </param>
 52        /// <param name="id"> The VM run command id. </param>
 53        /// <param name="osType"> The Operating System type. </param>
 54        /// <param name="label"> The VM run command label. </param>
 55        /// <param name="description"> The VM run command description. </param>
 56        /// <param name="script"> The script to be executed. </param>
 57        /// <param name="parameters"> The parameters used by the script. </param>
 458        internal RunCommandDocument(string schema, string id, OperatingSystemTypes osType, string label, string descript
 59        {
 460            if (schema == null)
 61            {
 062                throw new ArgumentNullException(nameof(schema));
 63            }
 464            if (id == null)
 65            {
 066                throw new ArgumentNullException(nameof(id));
 67            }
 468            if (label == null)
 69            {
 070                throw new ArgumentNullException(nameof(label));
 71            }
 472            if (description == null)
 73            {
 074                throw new ArgumentNullException(nameof(description));
 75            }
 76
 477            Script = script ?? new List<string>();
 478            Parameters = parameters;
 479        }
 80
 81        /// <summary> The script to be executed. </summary>
 882        public IReadOnlyList<string> Script { get; }
 83        /// <summary> The parameters used by the script. </summary>
 884        public IReadOnlyList<RunCommandParameterDefinition> Parameters { get; }
 85    }
 86}

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\RunCommandDocument.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 RunCommandDocument
 15    {
 16        internal static RunCommandDocument DeserializeRunCommandDocument(JsonElement element)
 17        {
 418            IReadOnlyList<string> script = default;
 419            IReadOnlyList<RunCommandParameterDefinition> parameters = default;
 420            string schema = default;
 421            string id = default;
 422            OperatingSystemTypes osType = default;
 423            string label = default;
 424            string description = default;
 6425            foreach (var property in element.EnumerateObject())
 26            {
 2827                if (property.NameEquals("script"))
 28                {
 429                    List<string> array = new List<string>();
 4830                    foreach (var item in property.Value.EnumerateArray())
 31                    {
 2032                        if (item.ValueKind == JsonValueKind.Null)
 33                        {
 034                            array.Add(null);
 35                        }
 36                        else
 37                        {
 2038                            array.Add(item.GetString());
 39                        }
 40                    }
 441                    script = array;
 442                    continue;
 43                }
 2444                if (property.NameEquals("parameters"))
 45                {
 446                    if (property.Value.ValueKind == JsonValueKind.Null)
 47                    {
 48                        continue;
 49                    }
 450                    List<RunCommandParameterDefinition> array = new List<RunCommandParameterDefinition>();
 2451                    foreach (var item in property.Value.EnumerateArray())
 52                    {
 853                        if (item.ValueKind == JsonValueKind.Null)
 54                        {
 055                            array.Add(null);
 56                        }
 57                        else
 58                        {
 859                            array.Add(RunCommandParameterDefinition.DeserializeRunCommandParameterDefinition(item));
 60                        }
 61                    }
 462                    parameters = array;
 463                    continue;
 64                }
 2065                if (property.NameEquals("$schema"))
 66                {
 467                    schema = property.Value.GetString();
 468                    continue;
 69                }
 1670                if (property.NameEquals("id"))
 71                {
 472                    id = property.Value.GetString();
 473                    continue;
 74                }
 1275                if (property.NameEquals("osType"))
 76                {
 477                    osType = property.Value.GetString().ToOperatingSystemTypes();
 478                    continue;
 79                }
 880                if (property.NameEquals("label"))
 81                {
 482                    label = property.Value.GetString();
 483                    continue;
 84                }
 485                if (property.NameEquals("description"))
 86                {
 487                    description = property.Value.GetString();
 88                    continue;
 89                }
 90            }
 491            return new RunCommandDocument(schema, id, osType, label, description, script, parameters);
 92        }
 93    }
 94}