< Summary

Information
Class: Ice.Internal.UdpConnector
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Internal/UdpConnector.cs
Tag: 71_18251537082
Line coverage
82%
Covered lines: 32
Uncovered lines: 7
Coverable lines: 39
Total lines: 90
Line coverage: 82%
Branch coverage
57%
Covered branches: 8
Total branches: 14
Branch coverage: 57.1%
Method coverage
83%
Covered methods: 5
Total methods: 6
Method coverage: 83.3%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
connect()100%11100%
type()100%210%
.ctor(...)100%11100%
Equals(...)58.33%18.561264.29%
ToString()100%11100%
GetHashCode()50%2.01287.5%

File(s)

/home/runner/work/ice/ice/csharp/src/Ice/Internal/UdpConnector.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Net;
 4
 5namespace Ice.Internal;
 6
 7internal sealed class UdpConnector : Connector
 8{
 19    public Transceiver connect() => new UdpTransceiver(_instance, _addr, _sourceAddr, _mcastInterface, _mcastTtl);
 10
 011    public short type() => _instance.type();
 12
 13    //
 14    // Only for use by UdpEndpointI
 15    //
 116    internal UdpConnector(
 117        ProtocolInstance instance,
 118        EndPoint addr,
 119        EndPoint sourceAddr,
 120        string mcastInterface,
 121        int mcastTtl,
 122        string connectionId)
 23    {
 124        _instance = instance;
 125        _addr = addr;
 126        _sourceAddr = sourceAddr;
 127        _mcastInterface = mcastInterface;
 128        _mcastTtl = mcastTtl;
 129        _connectionId = connectionId;
 130    }
 31
 32    public override bool Equals(object obj)
 33    {
 134        if (!(obj is UdpConnector))
 35        {
 036            return false;
 37        }
 38
 139        if (this == obj)
 40        {
 141            return true;
 42        }
 43
 144        var p = (UdpConnector)obj;
 145        if (!_connectionId.Equals(p._connectionId, StringComparison.Ordinal))
 46        {
 047            return false;
 48        }
 49
 150        if (!_mcastInterface.Equals(p._mcastInterface, StringComparison.Ordinal))
 51        {
 052            return false;
 53        }
 54
 155        if (_mcastTtl != p._mcastTtl)
 56        {
 057            return false;
 58        }
 59
 160        if (!Network.addressEquals(_sourceAddr, p._sourceAddr))
 61        {
 062            return false;
 63        }
 64
 165        return _addr.Equals(p._addr);
 66    }
 67
 168    public override string ToString() => Network.addrToString(_addr);
 69
 70    public override int GetHashCode()
 71    {
 172        var hash = new HashCode();
 173        hash.Add(_addr);
 174        if (_sourceAddr is not null)
 75        {
 076            hash.Add(_sourceAddr);
 77        }
 178        hash.Add(_mcastInterface);
 179        hash.Add(_mcastTtl);
 180        hash.Add(_connectionId);
 181        return hash.ToHashCode();
 82    }
 83
 84    private readonly ProtocolInstance _instance;
 85    private readonly EndPoint _addr;
 86    private readonly EndPoint _sourceAddr;
 87    private readonly string _mcastInterface;
 88    private readonly int _mcastTtl;
 89    private readonly string _connectionId;
 90}