< Summary

Class:Microsoft.Azure.Search.Models.TruncateTokenFilter
Assembly:Microsoft.Azure.Search.Service
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\Models\TruncateTokenFilter.cs
Covered lines:9
Uncovered lines:1
Coverable lines:10
Total lines:78
Line coverage:90% (9 of 10)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Length()-100%100%
Validate()-75%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\Models\TruncateTokenFilter.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.Search.Models
 12{
 13    using Microsoft.Rest;
 14    using Newtonsoft.Json;
 15    using System.Linq;
 16
 17    /// <summary>
 18    /// Truncates the terms to a specific length. This token filter is
 19    /// implemented using Apache Lucene.
 20    /// <see
 21    /// href="http://lucene.apache.org/core/4_10_3/analyzers-common/org/apache/lucene/analysis/miscellaneous/TruncateTok
 22    /// />
 23    /// </summary>
 24    [Newtonsoft.Json.JsonObject("#Microsoft.Azure.Search.TruncateTokenFilter")]
 25    public partial class TruncateTokenFilter : TokenFilter
 26    {
 27        /// <summary>
 28        /// Initializes a new instance of the TruncateTokenFilter class.
 29        /// </summary>
 430        public TruncateTokenFilter()
 31        {
 32            CustomInit();
 433        }
 34
 35        /// <summary>
 36        /// Initializes a new instance of the TruncateTokenFilter class.
 37        /// </summary>
 38        /// <param name="name">The name of the token filter. It must only
 39        /// contain letters, digits, spaces, dashes or underscores, can only
 40        /// start and end with alphanumeric characters, and is limited to 128
 41        /// characters.</param>
 42        /// <param name="length">The length at which terms will be truncated.
 43        /// Default and maximum is 300.</param>
 44        public TruncateTokenFilter(string name, int? length = default(int?))
 645            : base(name)
 46        {
 647            Length = length;
 48            CustomInit();
 649        }
 50
 51        /// <summary>
 52        /// An initialization method that performs custom operations like setting defaults
 53        /// </summary>
 54        partial void CustomInit();
 55
 56        /// <summary>
 57        /// Gets or sets the length at which terms will be truncated. Default
 58        /// and maximum is 300.
 59        /// </summary>
 60        [JsonProperty(PropertyName = "length")]
 2661        public int? Length { get; set; }
 62
 63        /// <summary>
 64        /// Validate the object.
 65        /// </summary>
 66        /// <exception cref="ValidationException">
 67        /// Thrown if validation fails
 68        /// </exception>
 69        public override void Validate()
 70        {
 471            base.Validate();
 472            if (Length > 300)
 73            {
 074                throw new ValidationException(ValidationRules.InclusiveMaximum, "Length", 300);
 75            }
 476        }
 77    }
 78}