< Summary

Class:Microsoft.Azure.Search.Models.Internal.SearchContinuationTokenComparer
Assembly:Microsoft.Azure.Search.Data
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Data\src\Customizations\Documents\Models\SearchContinuationTokenComparer.cs
Covered lines:24
Uncovered lines:2
Coverable lines:26
Total lines:69
Line coverage:92.3% (24 of 26)
Covered branches:32
Total branches:58
Branch coverage:55.1% (32 of 58)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
Equals(...)-100%50%
GetHashCode(...)-0%0%
NextPageParametersEquals(...)-95.65%58.7%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Data\src\Customizations\Documents\Models\SearchContinuationTokenComparer.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.Internal
 6{
 7    using System.Collections.Generic;
 8    using System.Linq;
 9
 10    /// <summary>
 11    /// Compares two <c cref="SearchContinuationToken">SearchContinuationToken</c> instances for equality.
 12    /// </summary>
 13    /// <para>
 14    /// This class is part of the internal implementation of the Azure Cognitive Search .NET SDK. It is not intended to 
 15    /// application code.
 16    /// </para>
 17    public class SearchContinuationTokenComparer : IEqualityComparer<SearchContinuationToken>
 18    {
 19        /// <summary>
 20        /// Compares the two given continuation tokens for equality.
 21        /// </summary>
 22        /// <param name="first">The first continuation token to compare.</param>
 23        /// <param name="second">The second continuation token to compare.</param>
 24        /// <returns><c>true</c> if the two tokens are equal, <c>false</c> otherwise.</returns>
 25        public bool Equals(SearchContinuationToken first, SearchContinuationToken second) =>
 426            first?.NextLink == second?.NextLink &&
 427            NextPageParametersEquals(first?.NextPageParameters, second?.NextPageParameters);
 28
 29        /// <summary>
 30        /// Returns a hash code for the specified object.
 31        /// </summary>
 32        /// <param name="obj">The object for which a hash code is to be returned.</param>
 33        /// <returns>A hash code for the specified object.</returns>
 034        public int GetHashCode(SearchContinuationToken obj) => obj?.GetHashCode() ?? 0;
 35
 36        private static bool NextPageParametersEquals(SearchRequest first, SearchRequest second)
 37        {
 438            if (first == null && second == null)
 39            {
 240                return true;
 41            }
 42
 243            if ((first == null) != (second == null))
 44            {
 045                return false;
 46            }
 47
 248            return
 249                first.IncludeTotalResultCount == second.IncludeTotalResultCount &&
 250                ((first.Facets == null && second.Facets == null) || first.Facets.SequenceEqual(second.Facets)) &&
 251                first.Filter == second.Filter &&
 252                first.HighlightFields == second.HighlightFields &&
 253                first.HighlightPostTag == second.HighlightPostTag &&
 254                first.HighlightPreTag == second.HighlightPreTag &&
 255                first.MinimumCoverage == second.MinimumCoverage &&
 256                first.OrderBy == second.OrderBy &&
 257                first.QueryType == second.QueryType &&
 258                ((first.ScoringParameters == null && second.ScoringParameters == null) ||
 259                  first.ScoringParameters.SequenceEqual(second.ScoringParameters)) &&
 260                first.ScoringProfile == second.ScoringProfile &&
 261                first.SearchText == second.SearchText &&
 262                first.SearchFields == second.SearchFields &&
 263                first.SearchMode == second.SearchMode &&
 264                first.Select == second.Select &&
 265                first.Skip == second.Skip &&
 266                first.Top == second.Top;
 67        }
 68    }
 69}