< Summary

Class:Microsoft.Azure.Search.Models.FieldMapping
Assembly:Microsoft.Azure.Search.Service
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\Indexers\Models\FieldMapping.Customization.cs
C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\Models\FieldMapping.cs
Covered lines:16
Uncovered lines:1
Coverable lines:17
Total lines:113
Line coverage:94.1% (16 of 17)
Covered branches:3
Total branches:4
Branch coverage:75% (3 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
get_SourceFieldName()-100%100%
get_TargetFieldName()-100%100%
get_MappingFunction()-100%100%
Validate()-80%75%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\Indexers\Models\FieldMapping.Customization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5namespace Microsoft.Azure.Search.Models
 6{
 7    public partial class FieldMapping
 8    {
 9        /// <summary>
 10        /// Initializes a new instance of the FieldMapping class.
 11        /// </summary>
 12        /// <param name="sourceFieldName">The name of the field in the data source.</param>
 13        /// <param name="mappingFunction">A function to apply to each source field value before indexing.</param>
 16014        public FieldMapping(string sourceFieldName, FieldMappingFunction mappingFunction) : this(sourceFieldName, source
 15        {
 16            // Other constructor does all initialization.
 16017        }
 18    }
 19}

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\Models\FieldMapping.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    /// Defines a mapping between a field in a data source and a target field
 19    /// in an index.
 20    /// <see
 21    /// href="https://docs.microsoft.com/azure/search/search-indexer-field-mappings"
 22    /// />
 23    /// </summary>
 24    public partial class FieldMapping
 25    {
 26        /// <summary>
 27        /// Initializes a new instance of the FieldMapping class.
 28        /// </summary>
 33629        public FieldMapping()
 30        {
 31            CustomInit();
 33632        }
 33
 34        /// <summary>
 35        /// Initializes a new instance of the FieldMapping class.
 36        /// </summary>
 37        /// <param name="sourceFieldName">The name of the field in the data
 38        /// source.</param>
 39        /// <param name="targetFieldName">The name of the target field in the
 40        /// index. Same as the source field name by default.</param>
 41        /// <param name="mappingFunction">A function to apply to each source
 42        /// field value before indexing.</param>
 26043        public FieldMapping(string sourceFieldName, string targetFieldName = default(string), FieldMappingFunction mappi
 44        {
 26045            SourceFieldName = sourceFieldName;
 26046            TargetFieldName = targetFieldName;
 26047            MappingFunction = mappingFunction;
 48            CustomInit();
 26049        }
 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 name of the field in the data source.
 58        /// </summary>
 59        [JsonProperty(PropertyName = "sourceFieldName")]
 136460        public string SourceFieldName { get; set; }
 61
 62        /// <summary>
 63        /// Gets or sets the name of the target field in the index. Same as the
 64        /// source field name by default.
 65        /// </summary>
 66        [JsonProperty(PropertyName = "targetFieldName")]
 103267        public string TargetFieldName { get; set; }
 68
 69        /// <summary>
 70        /// Gets or sets a function to apply to each source field value before
 71        /// indexing.
 72        /// </summary>
 73        [JsonProperty(PropertyName = "mappingFunction")]
 202074        public FieldMappingFunction MappingFunction { get; set; }
 75
 76        /// <summary>
 77        /// Validate the object.
 78        /// </summary>
 79        /// <exception cref="ValidationException">
 80        /// Thrown if validation fails
 81        /// </exception>
 82        public virtual void Validate()
 83        {
 33284            if (SourceFieldName == null)
 85            {
 086                throw new ValidationException(ValidationRules.CannotBeNull, "SourceFieldName");
 87            }
 33288            if (MappingFunction != null)
 89            {
 32890                MappingFunction.Validate();
 91            }
 33292        }
 93    }
 94}