< Summary

Class:Azure.Iot.Hub.Service.Models.AuthenticationMechanism
Assembly:Azure.Iot.Hub.Service
File(s):C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\AuthenticationMechanism.cs
C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\AuthenticationMechanism.Serialization.cs
Covered lines:35
Uncovered lines:0
Coverable lines:35
Total lines:98
Line coverage:100% (35 of 35)
Covered branches:14
Total branches:14
Branch coverage:100% (14 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_SymmetricKey()-100%100%
get_X509Thumbprint()-100%100%
get_Type()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeAuthenticationMechanism(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\AuthenticationMechanism.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
 8namespace Azure.Iot.Hub.Service.Models
 9{
 10    /// <summary> The AuthenticationMechanism. </summary>
 11    public partial class AuthenticationMechanism
 12    {
 13        /// <summary> Initializes a new instance of AuthenticationMechanism. </summary>
 8014        public AuthenticationMechanism()
 15        {
 8016        }
 17
 18        /// <summary> Initializes a new instance of AuthenticationMechanism. </summary>
 19        /// <param name="symmetricKey"> The primary and secondary keys used for SAS based authentication. </param>
 20        /// <param name="x509Thumbprint"> The primary and secondary x509 thumbprints used for x509 based authentication.
 21        /// <param name="type"> The type of authentication used to connect to the service. </param>
 23222        internal AuthenticationMechanism(SymmetricKey symmetricKey, X509Thumbprint x509Thumbprint, AuthenticationMechani
 23        {
 23224            SymmetricKey = symmetricKey;
 23225            X509Thumbprint = x509Thumbprint;
 23226            Type = type;
 23227        }
 28
 29        /// <summary> The primary and secondary keys used for SAS based authentication. </summary>
 39230        public SymmetricKey SymmetricKey { get; set; }
 31        /// <summary> The primary and secondary x509 thumbprints used for x509 based authentication. </summary>
 39232        public X509Thumbprint X509Thumbprint { get; set; }
 33        /// <summary> The type of authentication used to connect to the service. </summary>
 59234        public AuthenticationMechanismType? Type { get; set; }
 35    }
 36}

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\AuthenticationMechanism.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.Iot.Hub.Service.Models
 12{
 13    public partial class AuthenticationMechanism : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 12017            writer.WriteStartObject();
 12018            if (Optional.IsDefined(SymmetricKey))
 19            {
 4020                writer.WritePropertyName("symmetricKey");
 4021                writer.WriteObjectValue(SymmetricKey);
 22            }
 12023            if (Optional.IsDefined(X509Thumbprint))
 24            {
 4025                writer.WritePropertyName("x509Thumbprint");
 4026                writer.WriteObjectValue(X509Thumbprint);
 27            }
 12028            if (Optional.IsDefined(Type))
 29            {
 12030                writer.WritePropertyName("type");
 12031                writer.WriteStringValue(Type.Value.ToString());
 32            }
 12033            writer.WriteEndObject();
 12034        }
 35
 36        internal static AuthenticationMechanism DeserializeAuthenticationMechanism(JsonElement element)
 37        {
 23238            Optional<SymmetricKey> symmetricKey = default;
 23239            Optional<X509Thumbprint> x509Thumbprint = default;
 23240            Optional<AuthenticationMechanismType> type = default;
 185641            foreach (var property in element.EnumerateObject())
 42            {
 69643                if (property.NameEquals("symmetricKey"))
 44                {
 23245                    symmetricKey = SymmetricKey.DeserializeSymmetricKey(property.Value);
 23246                    continue;
 47                }
 46448                if (property.NameEquals("x509Thumbprint"))
 49                {
 23250                    x509Thumbprint = X509Thumbprint.DeserializeX509Thumbprint(property.Value);
 23251                    continue;
 52                }
 23253                if (property.NameEquals("type"))
 54                {
 23255                    type = new AuthenticationMechanismType(property.Value.GetString());
 56                    continue;
 57                }
 58            }
 23259            return new AuthenticationMechanism(symmetricKey.Value, x509Thumbprint.Value, Optional.ToNullable(type));
 60        }
 61    }
 62}