< Summary

Class:Azure.Search.Documents.Indexes.Models.CognitiveServicesAccountKey
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CognitiveServicesAccountKey.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CognitiveServicesAccountKey.Serialization.cs
Covered lines:31
Uncovered lines:3
Coverable lines:34
Total lines:98
Line coverage:91.1% (31 of 34)
Covered branches:11
Total branches:14
Branch coverage:78.5% (11 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
.ctor(...)-100%50%
get_Key()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-80%50%
DeserializeCognitiveServicesAccountKey(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CognitiveServicesAccountKey.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.Search.Documents.Indexes.Models
 11{
 12    /// <summary> A cognitive service resource provisioned with a key that is attached to a skillset. </summary>
 13    public partial class CognitiveServicesAccountKey : CognitiveServicesAccount
 14    {
 15        /// <summary> Initializes a new instance of CognitiveServicesAccountKey. </summary>
 16        /// <param name="key"> The key used to provision the cognitive service resource attached to a skillset. </param>
 17        /// <exception cref="ArgumentNullException"> <paramref name="key"/> is null. </exception>
 118        public CognitiveServicesAccountKey(string key)
 19        {
 120            if (key == null)
 21            {
 022                throw new ArgumentNullException(nameof(key));
 23            }
 24
 125            Key = key;
 126            ODataType = "#Microsoft.Azure.Search.CognitiveServicesByKey";
 127        }
 28
 29        /// <summary> Initializes a new instance of CognitiveServicesAccountKey. </summary>
 30        /// <param name="oDataType"> Identifies the concrete type of the cognitive service resource attached to a skills
 31        /// <param name="description"> Description of the cognitive service resource attached to a skillset. </param>
 32        /// <param name="key"> The key used to provision the cognitive service resource attached to a skillset. </param>
 133        internal CognitiveServicesAccountKey(string oDataType, string description, string key) : base(oDataType, descrip
 34        {
 135            Key = key;
 136            ODataType = oDataType ?? "#Microsoft.Azure.Search.CognitiveServicesByKey";
 137        }
 38
 39        /// <summary> The key used to provision the cognitive service resource attached to a skillset. </summary>
 340        public string Key { get; set; }
 41    }
 42}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CognitiveServicesAccountKey.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.Search.Documents.Indexes.Models
 12{
 13    public partial class CognitiveServicesAccountKey : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 117            writer.WriteStartObject();
 118            writer.WritePropertyName("key");
 119            writer.WriteStringValue(Key);
 120            writer.WritePropertyName("@odata.type");
 121            writer.WriteStringValue(ODataType);
 122            if (Optional.IsDefined(Description))
 23            {
 024                writer.WritePropertyName("description");
 025                writer.WriteStringValue(Description);
 26            }
 127            writer.WriteEndObject();
 128        }
 29
 30        internal static CognitiveServicesAccountKey DeserializeCognitiveServicesAccountKey(JsonElement element)
 31        {
 132            string key = default;
 133            string odataType = default;
 134            Optional<string> description = default;
 835            foreach (var property in element.EnumerateObject())
 36            {
 337                if (property.NameEquals("key"))
 38                {
 139                    key = property.Value.GetString();
 140                    continue;
 41                }
 242                if (property.NameEquals("@odata.type"))
 43                {
 144                    odataType = property.Value.GetString();
 145                    continue;
 46                }
 147                if (property.NameEquals("description"))
 48                {
 149                    description = property.Value.GetString();
 50                    continue;
 51                }
 52            }
 153            return new CognitiveServicesAccountKey(odataType, description.Value, key);
 54        }
 55    }
 56}