< Summary

Class:Microsoft.Azure.Search.Models.PatternReplaceCharFilter
Assembly:Microsoft.Azure.Search.Service
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\Models\PatternReplaceCharFilter.cs
Covered lines:12
Uncovered lines:2
Coverable lines:14
Total lines:92
Line coverage:85.7% (12 of 14)
Covered branches:2
Total branches:4
Branch coverage:50% (2 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Pattern()-100%100%
get_Replacement()-100%100%
Validate()-66.67%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\Models\PatternReplaceCharFilter.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    /// A character filter that replaces characters in the input string. It
 19    /// uses a regular expression to identify character sequences to preserve
 20    /// and a replacement pattern to identify characters to replace. For
 21    /// example, given the input text "aa bb aa bb", pattern "(aa)\s+(bb)", and
 22    /// replacement "$1#$2", the result would be "aa#bb aa#bb". This character
 23    /// filter is implemented using Apache Lucene.
 24    /// <see
 25    /// href="https://lucene.apache.org/core/4_10_3/analyzers-common/org/apache/lucene/analysis/pattern/PatternReplaceCh
 26    /// />
 27    /// </summary>
 28    [Newtonsoft.Json.JsonObject("#Microsoft.Azure.Search.PatternReplaceCharFilter")]
 29    public partial class PatternReplaceCharFilter : CharFilter
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the PatternReplaceCharFilter class.
 33        /// </summary>
 434        public PatternReplaceCharFilter()
 35        {
 36            CustomInit();
 437        }
 38
 39        /// <summary>
 40        /// Initializes a new instance of the PatternReplaceCharFilter class.
 41        /// </summary>
 42        /// <param name="name">The name of the char filter. It must only
 43        /// contain letters, digits, spaces, dashes or underscores, can only
 44        /// start and end with alphanumeric characters, and is limited to 128
 45        /// characters.</param>
 46        /// <param name="pattern">A regular expression pattern.</param>
 47        /// <param name="replacement">The replacement text.</param>
 48        public PatternReplaceCharFilter(string name, string pattern, string replacement)
 449            : base(name)
 50        {
 451            Pattern = pattern;
 452            Replacement = replacement;
 53            CustomInit();
 454        }
 55
 56        /// <summary>
 57        /// An initialization method that performs custom operations like setting defaults
 58        /// </summary>
 59        partial void CustomInit();
 60
 61        /// <summary>
 62        /// Gets or sets a regular expression pattern.
 63        /// </summary>
 64        [JsonProperty(PropertyName = "pattern")]
 2065        public string Pattern { get; set; }
 66
 67        /// <summary>
 68        /// Gets or sets the replacement text.
 69        /// </summary>
 70        [JsonProperty(PropertyName = "replacement")]
 2071        public string Replacement { get; set; }
 72
 73        /// <summary>
 74        /// Validate the object.
 75        /// </summary>
 76        /// <exception cref="ValidationException">
 77        /// Thrown if validation fails
 78        /// </exception>
 79        public override void Validate()
 80        {
 481            base.Validate();
 482            if (Pattern == null)
 83            {
 084                throw new ValidationException(ValidationRules.CannotBeNull, "Pattern");
 85            }
 486            if (Replacement == null)
 87            {
 088                throw new ValidationException(ValidationRules.CannotBeNull, "Replacement");
 89            }
 490        }
 91    }
 92}