< Summary

Class:Azure.Search.Documents.Indexes.Models.ScoringProfile
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringProfile.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringProfile.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\ScoringProfile.cs
Covered lines:51
Uncovered lines:7
Coverable lines:58
Total lines:158
Line coverage:87.9% (51 of 58)
Covered branches:21
Total branches:26
Branch coverage:80.7% (21 of 26)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
.ctor(...)-100%100%
get_Name()-100%100%
get_TextWeights()-100%100%
get_FunctionAggregation()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-78.95%70%
DeserializeScoringProfile(...)-91.3%92.86%
get_Functions()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringProfile.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.Search.Documents.Indexes.Models
 13{
 14    /// <summary> Defines parameters for a search index that influence scoring in search queries. </summary>
 15    public partial class ScoringProfile
 16    {
 17        /// <summary> Initializes a new instance of ScoringProfile. </summary>
 18        /// <param name="name"> The name of the scoring profile. </param>
 19        /// <exception cref="ArgumentNullException"> <paramref name="name"/> is null. </exception>
 420        public ScoringProfile(string name)
 21        {
 422            if (name == null)
 23            {
 024                throw new ArgumentNullException(nameof(name));
 25            }
 26
 427            Name = name;
 428            Functions = new ChangeTrackingList<ScoringFunction>();
 429        }
 30
 31        /// <summary> Initializes a new instance of ScoringProfile. </summary>
 32        /// <param name="name"> The name of the scoring profile. </param>
 33        /// <param name="textWeights"> Parameters that boost scoring based on text matches in certain index fields. </pa
 34        /// <param name="functions"> The collection of functions that influence the scoring of documents. </param>
 35        /// <param name="functionAggregation"> A value indicating how the results of individual scoring functions should
 1036        internal ScoringProfile(string name, TextWeights textWeights, IList<ScoringFunction> functions, ScoringFunctionA
 37        {
 1038            Name = name;
 1039            TextWeights = textWeights;
 1040            Functions = functions;
 1041            FunctionAggregation = functionAggregation;
 1042        }
 43
 44        /// <summary> The name of the scoring profile. </summary>
 2845        public string Name { get; set; }
 46        /// <summary> Parameters that boost scoring based on text matches in certain index fields. </summary>
 1647        public TextWeights TextWeights { get; set; }
 48        /// <summary> A value indicating how the results of individual scoring functions should be combined. Defaults to
 2649        public ScoringFunctionAggregation? FunctionAggregation { get; set; }
 50    }
 51}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringProfile.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.Indexes.Models
 13{
 14    public partial class ScoringProfile : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 618            writer.WriteStartObject();
 619            writer.WritePropertyName("name");
 620            writer.WriteStringValue(Name);
 621            if (Optional.IsDefined(TextWeights))
 22            {
 023                if (TextWeights != null)
 24                {
 025                    writer.WritePropertyName("text");
 026                    writer.WriteObjectValue(TextWeights);
 27                }
 28                else
 29                {
 030                    writer.WriteNull("text");
 31                }
 32            }
 633            if (Optional.IsCollectionDefined(Functions))
 34            {
 635                writer.WritePropertyName("functions");
 636                writer.WriteStartArray();
 2437                foreach (var item in Functions)
 38                {
 639                    writer.WriteObjectValue(item);
 40                }
 641                writer.WriteEndArray();
 42            }
 643            if (Optional.IsDefined(FunctionAggregation))
 44            {
 645                writer.WritePropertyName("functionAggregation");
 646                writer.WriteStringValue(FunctionAggregation.Value.ToSerialString());
 47            }
 648            writer.WriteEndObject();
 649        }
 50
 51        internal static ScoringProfile DeserializeScoringProfile(JsonElement element)
 52        {
 1053            string name = default;
 1054            Optional<TextWeights> text = default;
 1055            Optional<IList<ScoringFunction>> functions = default;
 1056            Optional<ScoringFunctionAggregation> functionAggregation = default;
 10057            foreach (var property in element.EnumerateObject())
 58            {
 4059                if (property.NameEquals("name"))
 60                {
 1061                    name = property.Value.GetString();
 1062                    continue;
 63                }
 3064                if (property.NameEquals("text"))
 65                {
 1066                    if (property.Value.ValueKind == JsonValueKind.Null)
 67                    {
 1068                        text = null;
 1069                        continue;
 70                    }
 071                    text = TextWeights.DeserializeTextWeights(property.Value);
 072                    continue;
 73                }
 2074                if (property.NameEquals("functions"))
 75                {
 1076                    List<ScoringFunction> array = new List<ScoringFunction>();
 4077                    foreach (var item in property.Value.EnumerateArray())
 78                    {
 1079                        array.Add(ScoringFunction.DeserializeScoringFunction(item));
 80                    }
 1081                    functions = array;
 1082                    continue;
 83                }
 1084                if (property.NameEquals("functionAggregation"))
 85                {
 1086                    functionAggregation = property.Value.GetString().ToScoringFunctionAggregation();
 87                    continue;
 88                }
 89            }
 1090            return new ScoringProfile(name, text.Value, Optional.ToList(functions), Optional.ToNullable(functionAggregat
 91        }
 92    }
 93}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\ScoringProfile.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Collections.Generic;
 5using Azure.Core;
 6
 7namespace Azure.Search.Documents.Indexes.Models
 8{
 9    public partial class ScoringProfile
 10    {
 11        /// <summary> The collection of functions that influence the scoring of documents. </summary>
 1612        public IList<ScoringFunction> Functions { get; }
 13    }
 14}