< Summary

Class:Azure.Search.Documents.Indexes.Models.SynonymMap
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SynonymMap.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SynonymMap.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\SynonymMap.cs
Covered lines:62
Uncovered lines:6
Coverable lines:68
Total lines:197
Line coverage:91.1% (62 of 68)
Covered branches:19
Total branches:24
Branch coverage:79.1% (19 of 24)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Name()-100%100%
get_Synonyms()-100%100%
get_EncryptionKey()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-76.47%50%
DeserializeSynonymMap(...)-91.67%92.86%
.ctor(...)-100%100%
.ctor(...)-100%100%
get_ETag()-100%100%
set_ETag(...)-100%50%
get_Format()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SynonymMap.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> Represents a synonym map definition. </summary>
 13    public partial class SynonymMap
 14    {
 15
 16        /// <summary> Initializes a new instance of SynonymMap. </summary>
 17        /// <param name="name"> The name of the synonym map. </param>
 18        /// <param name="format"> The format of the synonym map. Only the &apos;solr&apos; format is currently supported
 19        /// <param name="synonyms"> A series of synonym rules in the specified synonym map format. The rules must be sep
 20        /// <param name="encryptionKey"> A description of an encryption key that you create in Azure Key Vault. This key
 21        /// <param name="Etag"> The ETag of the synonym map. </param>
 1222        internal SynonymMap(string name, string format, string synonyms, SearchResourceEncryptionKey encryptionKey, stri
 23        {
 1224            Name = name;
 1225            Format = format;
 1226            Synonyms = synonyms;
 1227            EncryptionKey = encryptionKey;
 1228            _etag = Etag;
 1229        }
 30
 31        /// <summary> The name of the synonym map. </summary>
 4132        public string Name { get; set; }
 33        /// <summary> A series of synonym rules in the specified synonym map format. The rules must be separated by newl
 3634        public string Synonyms { get; set; }
 35        /// <summary> A description of an encryption key that you create in Azure Key Vault. This key is used to provide
 1936        public SearchResourceEncryptionKey EncryptionKey { get; set; }
 37    }
 38}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SynonymMap.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 SynonymMap : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 717            writer.WriteStartObject();
 718            writer.WritePropertyName("name");
 719            writer.WriteStringValue(Name);
 720            writer.WritePropertyName("format");
 721            writer.WriteStringValue(Format);
 722            writer.WritePropertyName("synonyms");
 723            writer.WriteStringValue(Synonyms);
 724            if (Optional.IsDefined(EncryptionKey))
 25            {
 026                if (EncryptionKey != null)
 27                {
 028                    writer.WritePropertyName("encryptionKey");
 029                    writer.WriteObjectValue(EncryptionKey);
 30                }
 31                else
 32                {
 033                    writer.WriteNull("encryptionKey");
 34                }
 35            }
 736            if (Optional.IsDefined(_etag))
 37            {
 438                writer.WritePropertyName("@odata.etag");
 439                writer.WriteStringValue(_etag);
 40            }
 741            writer.WriteEndObject();
 742        }
 43
 44        internal static SynonymMap DeserializeSynonymMap(JsonElement element)
 45        {
 946            string name = default;
 947            string format = default;
 948            string synonyms = default;
 949            Optional<SearchResourceEncryptionKey> encryptionKey = default;
 950            Optional<string> odataEtag = default;
 10651            foreach (var property in element.EnumerateObject())
 52            {
 4453                if (property.NameEquals("name"))
 54                {
 955                    name = property.Value.GetString();
 956                    continue;
 57                }
 3558                if (property.NameEquals("format"))
 59                {
 760                    format = property.Value.GetString();
 761                    continue;
 62                }
 2863                if (property.NameEquals("synonyms"))
 64                {
 765                    synonyms = property.Value.GetString();
 766                    continue;
 67                }
 2168                if (property.NameEquals("encryptionKey"))
 69                {
 770                    if (property.Value.ValueKind == JsonValueKind.Null)
 71                    {
 772                        encryptionKey = null;
 773                        continue;
 74                    }
 075                    encryptionKey = SearchResourceEncryptionKey.DeserializeSearchResourceEncryptionKey(property.Value);
 076                    continue;
 77                }
 1478                if (property.NameEquals("@odata.etag"))
 79                {
 780                    odataEtag = property.Value.GetString();
 81                    continue;
 82                }
 83            }
 984            return new SynonymMap(name, format, synonyms, encryptionKey.Value, odataEtag.Value);
 85        }
 86    }
 87}

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.IO;
 6using Azure.Core;
 7
 8namespace Azure.Search.Documents.Indexes.Models
 9{
 10    [CodeGenSuppress(nameof(SynonymMap), typeof(string), typeof(string))]
 11    public partial class SynonymMap
 12    {
 13        private const string DefaultFormat = "solr";
 14
 15        [CodeGenMember("etag")]
 16        private string _etag;
 17
 18        // TODO: Replace constructor and read-only properties when https://github.com/Azure/autorest.csharp/issues/554 i
 19
 20        /// <summary>
 21        /// Initializes a new instance of the <see cref="SynonymMap"/> class.
 22        /// </summary>
 23        /// <param name="name">The name of the synonym map.</param>
 24        /// <param name="synonyms">
 25        /// The formatted synonyms string to define.
 26        /// Because only the "solr" synonym map format is currently supported, these are values delimited by "\n".
 27        /// </param>
 28        /// <exception cref="ArgumentException"><paramref name="name"/> or <paramref name="synonyms"/> is an empty strin
 29        /// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="synonyms"/> is null.</exc
 1130        public SynonymMap(string name, string synonyms)
 31        {
 1132            Argument.AssertNotNullOrEmpty(name, nameof(name));
 933            Argument.AssertNotNullOrEmpty(synonyms, nameof(synonyms));
 34
 735            Name = name;
 736            Format = DefaultFormat;
 737            Synonyms = synonyms;
 738        }
 39
 40        /// <summary>
 41        /// Initializes a new instance of the <see cref="SynonymMap"/> class.
 42        /// </summary>
 43        /// <param name="name">The name of the synonym map.</param>
 44        /// <param name="reader">
 45        /// A <see cref="TextReader"/> from which formatted synonyms are read.
 46        /// Because only the "solr" synonym map format is currently supported, these are values delimited by "\n".
 47        /// </param>
 48        /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception>
 49        /// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="reader"/> is null.</excep
 450        public SynonymMap(string name, TextReader reader)
 51        {
 452            Argument.AssertNotNullOrEmpty(name, nameof(name));
 253            Argument.AssertNotNull(reader, nameof(reader));
 54
 155            Name = name;
 156            Format = DefaultFormat;
 157            Synonyms = reader.ReadToEnd();
 158        }
 59
 60        /// <summary>
 61        /// The <see cref="Azure.ETag"/> of the <see cref="SynonymMap"/>.
 62        /// </summary>
 63        public ETag? ETag
 64        {
 1365            get => _etag is null ? (ETag?)null : new ETag(_etag);
 466            set => _etag = value?.ToString();
 67        }
 68
 69        /// <summary> The format of the synonym map. Only the "solr" format is currently supported. </summary>
 3170        internal string Format { get; set; }
 71    }
 72}