< Summary

Information
Class: Elsa.Workflows.Activities.Flowchart.Serialization.ConnectionComparer
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Serialization/ConnectionComparer.cs
Line coverage
25%
Covered lines: 2
Uncovered lines: 6
Coverable lines: 8
Total lines: 35
Line coverage: 25%
Branch coverage
16%
Covered branches: 7
Total branches: 42
Branch coverage: 16.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Equals(...)3.33%5973014.28%
GetHashCode(...)50%1212100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Serialization/ConnectionComparer.cs

#LineLine coverage
 1using Elsa.Workflows.Activities.Flowchart.Models;
 2
 3namespace Elsa.Workflows.Activities.Flowchart.Serialization;
 4
 5/// <summary>
 6/// Compares two <see cref="Connection"/> instances.
 7/// </summary>
 8public class ConnectionComparer : IEqualityComparer<Connection>
 9{
 10    /// <inheritdoc />
 11    public bool Equals(Connection? x, Connection? y)
 12    {
 213        if (ReferenceEquals(x, y)) return true;
 014        if (ReferenceEquals(x, null)) return false;
 015        if (ReferenceEquals(y, null)) return false;
 016        if (x.GetType() != y.GetType()) return false;
 17
 18        // ReSharper disable ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
 19        // Justification: These can be null when the designer is in an invalid state. For example, if a NotFoundActivity
 020        if (x.Source.Activity?.Id == null || x.Target.Activity?.Id == null || y.Source.Activity?.Id == null || y.Target.
 021            return false;
 22        // ReSharper restore ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
 23
 024        return x.Source.Activity.Id.Equals(y.Source.Activity.Id) && x.Target.Activity.Id.Equals(y.Target.Activity.Id) &&
 25    }
 26
 27    /// <inheritdoc />
 28    public int GetHashCode(Connection obj)
 29    {
 30        // ReSharper disable ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
 31        // Justification: These can be null when the designer is in an invalid state. For example, if it used a NotFound
 94532        return HashCode.Combine(obj.Source?.Activity?.Id, obj.Target?.Activity?.Id, obj.Source?.Port, obj.Target?.Port);
 33        // ReSharper restore ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
 34    }
 35}