< Summary

Class:Azure.Search.Documents.Indexes.Models.DistanceScoringFunction
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\DistanceScoringFunction.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\DistanceScoringFunction.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\DistanceScoringFunction.cs
Covered lines:46
Uncovered lines:0
Coverable lines:46
Total lines:129
Line coverage:100% (46 of 46)
Covered branches:15
Total branches:16
Branch coverage:93.7% (15 of 16)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%50%
get_Parameters()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeDistanceScoringFunction(...)-100%100%
.ctor(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\DistanceScoringFunction.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;
 9
 10namespace Azure.Search.Documents.Indexes.Models
 11{
 12    /// <summary> Defines a function that boosts scores based on distance from a geographic location. </summary>
 13    public partial class DistanceScoringFunction : ScoringFunction
 14    {
 15
 16        /// <summary> Initializes a new instance of DistanceScoringFunction. </summary>
 17        /// <param name="type"> Indicates the type of function to use. Valid values include magnitude, freshness, distan
 18        /// <param name="fieldName"> The name of the field used as input to the scoring function. </param>
 19        /// <param name="boost"> A multiplier for the raw score. Must be a positive number not equal to 1.0. </param>
 20        /// <param name="interpolation"> A value indicating how boosting will be interpolated across document scores; de
 21        /// <param name="parameters"> Parameter values for the distance scoring function. </param>
 1022        internal DistanceScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? inte
 23        {
 1024            Parameters = parameters;
 1025            Type = type ?? "distance";
 1026        }
 27
 28        /// <summary> Parameter values for the distance scoring function. </summary>
 2029        public DistanceScoringParameters Parameters { get; set; }
 30    }
 31}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\DistanceScoringFunction.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.Search.Documents.Indexes.Models
 12{
 13    public partial class DistanceScoringFunction : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 617            writer.WriteStartObject();
 618            writer.WritePropertyName("distance");
 619            writer.WriteObjectValue(Parameters);
 620            writer.WritePropertyName("type");
 621            writer.WriteStringValue(Type);
 622            writer.WritePropertyName("fieldName");
 623            writer.WriteStringValue(FieldName);
 624            writer.WritePropertyName("boost");
 625            writer.WriteNumberValue(Boost);
 626            if (Optional.IsDefined(Interpolation))
 27            {
 228                writer.WritePropertyName("interpolation");
 229                writer.WriteStringValue(Interpolation.Value.ToSerialString());
 30            }
 631            writer.WriteEndObject();
 632        }
 33
 34        internal static DistanceScoringFunction DeserializeDistanceScoringFunction(JsonElement element)
 35        {
 1036            DistanceScoringParameters distance = default;
 1037            string type = default;
 1038            string fieldName = default;
 1039            double boost = default;
 1040            Optional<ScoringFunctionInterpolation> interpolation = default;
 18041            foreach (var property in element.EnumerateObject())
 42            {
 8043                if (property.NameEquals("distance"))
 44                {
 1045                    distance = DistanceScoringParameters.DeserializeDistanceScoringParameters(property.Value);
 1046                    continue;
 47                }
 7048                if (property.NameEquals("type"))
 49                {
 1050                    type = property.Value.GetString();
 1051                    continue;
 52                }
 6053                if (property.NameEquals("fieldName"))
 54                {
 1055                    fieldName = property.Value.GetString();
 1056                    continue;
 57                }
 5058                if (property.NameEquals("boost"))
 59                {
 1060                    boost = property.Value.GetDouble();
 1061                    continue;
 62                }
 4063                if (property.NameEquals("interpolation"))
 64                {
 1065                    interpolation = property.Value.GetString().ToScoringFunctionInterpolation();
 66                    continue;
 67                }
 68            }
 1069            return new DistanceScoringFunction(type, fieldName, boost, Optional.ToNullable(interpolation), distance);
 70        }
 71    }
 72}

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using Azure.Core;
 6
 7namespace Azure.Search.Documents.Indexes.Models
 8{
 9    public partial class DistanceScoringFunction
 10    {
 11        /// <summary> Initializes a new instance of DistanceScoringFunction. </summary>
 12        /// <param name="fieldName"> The name of the field used as input to the scoring function. </param>
 13        /// <param name="boost"> A multiplier for the raw score. Must be a positive number not equal to 1.0. </param>
 14        /// <param name="parameters"> Parameter values for the distance scoring function. </param>
 15        /// <exception cref="ArgumentException"><paramref name="fieldName"/> is an empty string.</exception>
 16        /// <exception cref="ArgumentNullException"><paramref name="fieldName"/> or <paramref name="parameters"/> is nul
 417        public DistanceScoringFunction(string fieldName, double boost, DistanceScoringParameters parameters) : base(fiel
 18        {
 419            Argument.AssertNotNullOrEmpty(fieldName, nameof(fieldName));
 420            Argument.AssertNotNull(parameters, nameof(parameters));
 21
 422            Parameters = parameters;
 423            Type = "distance";
 424        }
 25    }
 26}