< Summary

Class:Azure.Core.XElementExtensions
Assembly:Azure.Iot.Hub.Service
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\XElementExtensions.cs
Covered lines:0
Uncovered lines:12
Coverable lines:12
Total lines:35
Line coverage:0% (0 of 12)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
GetBytesFromBase64Value(...)-0%0%
GetDateTimeOffsetValue(...)-0%0%
GetTimeSpanValue(...)-0%100%
GetObjectValue(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\XElementExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4#nullable enable
 5
 6using System;
 7using System.Globalization;
 8using System.Xml;
 9using System.Xml.Linq;
 10
 11namespace Azure.Core
 12{
 13    internal static class XElementExtensions
 14    {
 015        public static byte[] GetBytesFromBase64Value(this XElement element, string format) => format switch
 016        {
 017            "U" => TypeFormatters.FromBase64UrlString(element.Value),
 018            _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format))
 019        };
 20
 021        public static DateTimeOffset GetDateTimeOffsetValue(this XElement element, string format) => format switch
 022        {
 023            "U" => DateTimeOffset.FromUnixTimeSeconds((long)element),
 024            _ => TypeFormatters.ParseDateTimeOffset(element.Value, format)
 025        };
 26
 027        public static TimeSpan GetTimeSpanValue(this XElement element, string format) => TypeFormatters.ParseTimeSpan(el
 28        #pragma warning disable CA1801 //Parameter format of method GetObjectValue is never used. Remove the parameter o
 29        public static object GetObjectValue(this XElement element, string format)
 30        #pragma warning restore
 31        {
 032            return element.Value;
 33        }
 34    }
 35}