< Summary

Class:Azure.AI.FormRecognizer.Models.KeyValueElement
Assembly:Azure.AI.FormRecognizer
File(s):C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\KeyValueElement.cs
C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\KeyValueElement.Serialization.cs
Covered lines:33
Uncovered lines:7
Coverable lines:40
Total lines:112
Line coverage:82.5% (33 of 40)
Covered branches:16
Total branches:18
Branch coverage:88.8% (16 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-100%100%
get_Text()-100%100%
get_BoundingBox()-100%100%
get_Elements()-100%100%
DeserializeKeyValueElement(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\KeyValueElement.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 Azure.Core;
 11
 12namespace Azure.AI.FormRecognizer.Models
 13{
 14    /// <summary> Information about the extracted key or value in a key-value pair. </summary>
 15    internal partial class KeyValueElement
 16    {
 17        /// <summary> Initializes a new instance of KeyValueElement. </summary>
 18        /// <param name="text"> The text content of the key or value. </param>
 19        /// <exception cref="ArgumentNullException"> <paramref name="text"/> is null. </exception>
 020        internal KeyValueElement(string text)
 21        {
 022            if (text == null)
 23            {
 024                throw new ArgumentNullException(nameof(text));
 25            }
 26
 027            Text = text;
 028            BoundingBox = new ChangeTrackingList<float>();
 029            Elements = new ChangeTrackingList<string>();
 030        }
 31
 32        /// <summary> Initializes a new instance of KeyValueElement. </summary>
 33        /// <param name="text"> The text content of the key or value. </param>
 34        /// <param name="boundingBox"> Bounding box of the key or value. </param>
 35        /// <param name="elements"> When includeTextDetails is set to true, a list of references to the text elements co
 115236        internal KeyValueElement(string text, IReadOnlyList<float> boundingBox, IReadOnlyList<string> elements)
 37        {
 115238            Text = text;
 115239            BoundingBox = boundingBox;
 115240            Elements = elements;
 115241        }
 42
 43        /// <summary> The text content of the key or value. </summary>
 172844        public string Text { get; }
 45        /// <summary> Bounding box of the key or value. </summary>
 206446        public IReadOnlyList<float> BoundingBox { get; }
 47        /// <summary> When includeTextDetails is set to true, a list of references to the text elements constituting thi
 172848        public IReadOnlyList<string> Elements { get; }
 49    }
 50}

C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\KeyValueElement.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.AI.FormRecognizer.Models
 13{
 14    internal partial class KeyValueElement
 15    {
 16        internal static KeyValueElement DeserializeKeyValueElement(JsonElement element)
 17        {
 115218            string text = default;
 115219            Optional<IReadOnlyList<float>> boundingBox = default;
 115220            Optional<IReadOnlyList<string>> elements = default;
 921621            foreach (var property in element.EnumerateObject())
 22            {
 345623                if (property.NameEquals("text"))
 24                {
 115225                    text = property.Value.GetString();
 115226                    continue;
 27                }
 230428                if (property.NameEquals("boundingBox"))
 29                {
 115230                    if (property.Value.ValueKind == JsonValueKind.Null)
 31                    {
 24032                        boundingBox = null;
 24033                        continue;
 34                    }
 91235                    List<float> array = new List<float>();
 1641636                    foreach (var item in property.Value.EnumerateArray())
 37                    {
 729638                        array.Add(item.GetSingle());
 39                    }
 91240                    boundingBox = array;
 91241                    continue;
 42                }
 115243                if (property.NameEquals("elements"))
 44                {
 115245                    if (property.Value.ValueKind == JsonValueKind.Null)
 46                    {
 57647                        elements = null;
 57648                        continue;
 49                    }
 57650                    List<string> array = new List<string>();
 404851                    foreach (var item in property.Value.EnumerateArray())
 52                    {
 144853                        array.Add(item.GetString());
 54                    }
 57655                    elements = array;
 56                    continue;
 57                }
 58            }
 115259            return new KeyValueElement(text, Optional.ToList(boundingBox), Optional.ToList(elements));
 60        }
 61    }
 62}