< Summary

Class:ReactiveUI.Validation.Comparators.ValidationStateComparer
Assembly:ReactiveUI.Validation
File(s):D:\a\1\s\src\ReactiveUI.Validation\Comparators\ValidationStateComparer.cs
Covered lines:4
Uncovered lines:5
Coverable lines:9
Total lines:52
Line coverage:44.4% (4 of 9)
Covered branches:8
Total branches:14
Branch coverage:57.1% (8 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
Equals(...)-66.67%66.67%
GetHashCode(...)-0%0%

File(s)

D:\a\1\s\src\ReactiveUI.Validation\Comparators\ValidationStateComparer.cs

#LineLine coverage
 1// Copyright (c) 2020 .NET Foundation and Contributors. All rights reserved.
 2// Licensed to the .NET Foundation under one or more agreements.
 3// The .NET Foundation licenses this file to you under the MIT license.
 4// See the LICENSE file in the project root for full license information.
 5
 6using System;
 7using System.Collections.Generic;
 8using ReactiveUI.Validation.States;
 9
 10namespace ReactiveUI.Validation.Comparators
 11{
 12    /// <inheritdoc />
 13    /// <summary>
 14    /// Utility class used to compare <see cref="ReactiveUI.Validation.States.ValidationState" /> instances.
 15    /// </summary>
 16    public class ValidationStateComparer : EqualityComparer<ValidationState>
 17    {
 18        /// <summary>
 19        /// Checks if two <see cref="ValidationState"/> objects are equals based on both
 20        /// <see cref="ValidationState.IsValid"/> and <see cref="ValidationState.Component"/> properties.
 21        /// </summary>
 22        /// <param name="x">Source <see cref="ValidationState"/> object.</param>
 23        /// <param name="y">Target <see cref="ValidationState"/> object.</param>
 24        /// <returns>Returns true if both objects are equals, otherwise false.</returns>
 25        public override bool Equals(ValidationState x, ValidationState y)
 26        {
 5027            if (x == null && y == null)
 28            {
 029                return true;
 30            }
 31
 5032            if (x == null || y == null)
 33            {
 034                return false;
 35            }
 36
 5037            return x.IsValid == y.IsValid && x.Text.ToSingleLine() == y.Text.ToSingleLine()
 5038                                          && x.Component == y.Component;
 39        }
 40
 41        /// <inheritdoc />
 42        public override int GetHashCode(ValidationState obj)
 43        {
 044            if (obj == null)
 45            {
 046                throw new ArgumentNullException(nameof(obj));
 47            }
 48
 049            return obj.GetHashCode();
 50        }
 51    }
 52}

Methods/Properties

Equals(...)
GetHashCode(...)