< Summary

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

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\FreshnessScoringFunction.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 the value of a date-time field. </summary>
 13    public partial class FreshnessScoringFunction : ScoringFunction
 14    {
 15
 16        /// <summary> Initializes a new instance of FreshnessScoringFunction. </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 freshness scoring function. </param>
 022        internal FreshnessScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? int
 23        {
 024            Parameters = parameters;
 025            Type = type ?? "freshness";
 026        }
 27
 28        /// <summary> Parameter values for the freshness scoring function. </summary>
 029        public FreshnessScoringParameters Parameters { get; set; }
 30    }
 31}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\FreshnessScoringFunction.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 FreshnessScoringFunction : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 017            writer.WriteStartObject();
 018            writer.WritePropertyName("freshness");
 019            writer.WriteObjectValue(Parameters);
 020            writer.WritePropertyName("type");
 021            writer.WriteStringValue(Type);
 022            writer.WritePropertyName("fieldName");
 023            writer.WriteStringValue(FieldName);
 024            writer.WritePropertyName("boost");
 025            writer.WriteNumberValue(Boost);
 026            if (Optional.IsDefined(Interpolation))
 27            {
 028                writer.WritePropertyName("interpolation");
 029                writer.WriteStringValue(Interpolation.Value.ToSerialString());
 30            }
 031            writer.WriteEndObject();
 032        }
 33
 34        internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(JsonElement element)
 35        {
 036            FreshnessScoringParameters freshness = default;
 037            string type = default;
 038            string fieldName = default;
 039            double boost = default;
 040            Optional<ScoringFunctionInterpolation> interpolation = default;
 041            foreach (var property in element.EnumerateObject())
 42            {
 043                if (property.NameEquals("freshness"))
 44                {
 045                    freshness = FreshnessScoringParameters.DeserializeFreshnessScoringParameters(property.Value);
 046                    continue;
 47                }
 048                if (property.NameEquals("type"))
 49                {
 050                    type = property.Value.GetString();
 051                    continue;
 52                }
 053                if (property.NameEquals("fieldName"))
 54                {
 055                    fieldName = property.Value.GetString();
 056                    continue;
 57                }
 058                if (property.NameEquals("boost"))
 59                {
 060                    boost = property.Value.GetDouble();
 061                    continue;
 62                }
 063                if (property.NameEquals("interpolation"))
 64                {
 065                    interpolation = property.Value.GetString().ToScoringFunctionInterpolation();
 66                    continue;
 67                }
 68            }
 069            return new FreshnessScoringFunction(type, fieldName, boost, Optional.ToNullable(interpolation), freshness);
 70        }
 71    }
 72}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\FreshnessScoringFunction.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 FreshnessScoringFunction
 10    {
 11        /// <summary> Initializes a new instance of FreshnessScoringFunction. </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 freshness 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
 017        public FreshnessScoringFunction(string fieldName, double boost, FreshnessScoringParameters parameters) : base(fi
 18        {
 019            Argument.AssertNotNullOrEmpty(fieldName, nameof(fieldName));
 020            Argument.AssertNotNull(parameters, nameof(parameters));
 21
 022            Parameters = parameters;
 023            Type = "freshness";
 024        }
 25    }
 26}