< Summary

Information
Class: Ice.Internal.TcpConnector
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Internal/TcpConnector.cs
Tag: 71_18251537082
Line coverage
83%
Covered lines: 30
Uncovered lines: 6
Coverable lines: 36
Total lines: 85
Line coverage: 83.3%
Branch coverage
64%
Covered branches: 9
Total branches: 14
Branch coverage: 64.2%
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(...)60%13.71066.67%
ToString()100%22100%
GetHashCode()50%2.01285.71%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Net;
 4
 5namespace Ice.Internal;
 6
 7internal sealed class TcpConnector : Connector
 8{
 9    public Transceiver connect() =>
 110        new TcpTransceiver(_instance, new StreamSocket(_instance, _proxy, _addr, _sourceAddr));
 11
 012    public short type() => _instance.type();
 13
 14    //
 15    // Only for use by TcpEndpoint
 16    //
 117    internal TcpConnector(
 118        ProtocolInstance instance,
 119        EndPoint addr,
 120        NetworkProxy proxy,
 121        EndPoint sourceAddr,
 122        int timeout,
 123        string connectionId)
 24    {
 125        _instance = instance;
 126        _addr = addr;
 127        _proxy = proxy;
 128        _sourceAddr = sourceAddr;
 129        _timeout = timeout;
 130        _connectionId = connectionId;
 131    }
 32
 33    public override bool Equals(object obj)
 34    {
 135        if (!(obj is TcpConnector))
 36        {
 037            return false;
 38        }
 39
 140        if (this == obj)
 41        {
 142            return true;
 43        }
 44
 145        var p = (TcpConnector)obj;
 146        if (_timeout != p._timeout)
 47        {
 048            return false;
 49        }
 50
 151        if (!Network.addressEquals(_sourceAddr, p._sourceAddr))
 52        {
 053            return false;
 54        }
 55
 156        if (!_connectionId.Equals(p._connectionId, StringComparison.Ordinal))
 57        {
 058            return false;
 59        }
 60
 161        return _addr.Equals(p._addr);
 62    }
 63
 164    public override string ToString() => Network.addrToString(_proxy == null ? _addr : _proxy.getAddress());
 65
 66    public override int GetHashCode()
 67    {
 168        var hash = new HashCode();
 169        hash.Add(_addr);
 170        if (_sourceAddr is not null)
 71        {
 072            hash.Add(_sourceAddr);
 73        }
 174        hash.Add(_timeout);
 175        hash.Add(_connectionId);
 176        return hash.ToHashCode();
 77    }
 78
 79    private readonly ProtocolInstance _instance;
 80    private readonly EndPoint _addr;
 81    private readonly NetworkProxy _proxy;
 82    private readonly EndPoint _sourceAddr;
 83    private readonly int _timeout;
 84    private readonly string _connectionId;
 85}