< Summary

Class:Azure.Search.Documents.Models.SearchResult
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchResult.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchResult.Serialization.cs
Covered lines:0
Uncovered lines:42
Coverable lines:42
Total lines:113
Line coverage:0% (0 of 42)
Covered branches:0
Total branches:12
Branch coverage:0% (0 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%100%
.ctor(...)-0%100%
get_Score()-0%100%
get_Highlights()-0%100%
get_AdditionalProperties()-0%100%
GetEnumerator()-0%100%
System.Collections.IEnumerable.GetEnumerator()-0%100%
TryGetValue(...)-0%100%
ContainsKey(...)-0%100%
get_Keys()-0%100%
get_Values()-0%100%
System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.get_Count()-0%100%
get_Item(...)-0%100%
DeserializeSearchResult(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchResult.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;
 9using System.Collections.Generic;
 10using Azure.Core;
 11
 12namespace Azure.Search.Documents.Models
 13{
 14    /// <summary> Contains a document found by a search query, plus associated metadata. </summary>
 15    internal partial class SearchResult : IReadOnlyDictionary<string, object>
 16    {
 17        /// <summary> Initializes a new instance of SearchResult. </summary>
 18        /// <param name="score"> The relevance score of the document compared to other documents returned by the query. 
 019        internal SearchResult(double score)
 20        {
 021            Score = score;
 022            Highlights = new ChangeTrackingDictionary<string, IList<string>>();
 023            AdditionalProperties = new ChangeTrackingDictionary<string, object>();
 024        }
 25
 26        /// <summary> Initializes a new instance of SearchResult. </summary>
 27        /// <param name="score"> The relevance score of the document compared to other documents returned by the query. 
 28        /// <param name="highlights"> Text fragments from the document that indicate the matching search terms, organize
 29        /// <param name="additionalProperties"> . </param>
 030        internal SearchResult(double score, IReadOnlyDictionary<string, IList<string>> highlights, IReadOnlyDictionary<s
 31        {
 032            Score = score;
 033            Highlights = highlights;
 034            AdditionalProperties = additionalProperties;
 035        }
 36
 37        /// <summary> The relevance score of the document compared to other documents returned by the query. </summary>
 038        public double Score { get; }
 39        /// <summary> Text fragments from the document that indicate the matching search terms, organized by each applic
 040        public IReadOnlyDictionary<string, IList<string>> Highlights { get; }
 041        internal IReadOnlyDictionary<string, object> AdditionalProperties { get; }
 42        /// <inheritdoc />
 043        public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => AdditionalProperties.GetEnumerator();
 44        /// <inheritdoc />
 045        IEnumerator IEnumerable.GetEnumerator() => AdditionalProperties.GetEnumerator();
 46        /// <inheritdoc />
 047        public bool TryGetValue(string key, out object value) => AdditionalProperties.TryGetValue(key, out value);
 48        /// <inheritdoc />
 049        public bool ContainsKey(string key) => AdditionalProperties.ContainsKey(key);
 50        /// <inheritdoc />
 051        public IEnumerable<string> Keys => AdditionalProperties.Keys;
 52        /// <inheritdoc />
 053        public IEnumerable<object> Values => AdditionalProperties.Values;
 54        /// <inheritdoc />
 055        int IReadOnlyCollection<KeyValuePair<string, object>>.Count => AdditionalProperties.Count;
 56        /// <inheritdoc />
 57        public object this[string key]
 58        {
 059            get => AdditionalProperties[key];
 60        }
 61    }
 62}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchResult.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.Search.Documents.Models
 13{
 14    internal partial class SearchResult
 15    {
 16        internal static SearchResult DeserializeSearchResult(JsonElement element)
 17        {
 018            double searchScore = default;
 019            Optional<IReadOnlyDictionary<string, IList<string>>> searchHighlights = default;
 020            IReadOnlyDictionary<string, object> additionalProperties = default;
 021            Dictionary<string, object> additionalPropertiesDictionary = default;
 022            foreach (var property in element.EnumerateObject())
 23            {
 024                if (property.NameEquals("@search.score"))
 25                {
 026                    searchScore = property.Value.GetDouble();
 027                    continue;
 28                }
 029                if (property.NameEquals("@search.highlights"))
 30                {
 031                    Dictionary<string, IList<string>> dictionary = new Dictionary<string, IList<string>>();
 032                    foreach (var property0 in property.Value.EnumerateObject())
 33                    {
 034                        List<string> array = new List<string>();
 035                        foreach (var item in property0.Value.EnumerateArray())
 36                        {
 037                            array.Add(item.GetString());
 38                        }
 039                        dictionary.Add(property0.Name, array);
 40                    }
 041                    searchHighlights = dictionary;
 042                    continue;
 43                }
 044                additionalPropertiesDictionary ??= new Dictionary<string, object>();
 045                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
 46            }
 047            additionalProperties = additionalPropertiesDictionary;
 048            return new SearchResult(searchScore, Optional.ToDictionary(searchHighlights), additionalProperties);
 49        }
 50    }
 51}