< Summary

Information
Class: Ice.Internal.TcpConnector
Assembly: Ice
File(s): /_/csharp/src/Ice/Internal/TcpConnector.cs
Tag: 125_37167941578
Line coverage
83%
Covered lines: 31
Uncovered lines: 6
Coverable lines: 37
Total lines: 87
Line coverage: 83.7%
Branch coverage
64%
Covered branches: 9
Total branches: 14
Branch coverage: 64.2%
Method coverage
83%
Covered methods: 5
Fully covered methods: 3
Total methods: 6
Method coverage: 83.3%
Full method coverage: 50%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
connect()100%11100%
type()100%210%
.ctor(...)100%11100%
Equals(...)60%141066.67%
ToString()100%22100%
GetHashCode()50%2285.71%

File(s)

/_/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, _bufSize));
 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        _bufSize = new TcpBufSize(instance.properties());
 132    }
 33
 34    public override bool Equals(object obj)
 35    {
 136        if (!(obj is TcpConnector))
 37        {
 038            return false;
 39        }
 40
 141        if (this == obj)
 42        {
 143            return true;
 44        }
 45
 146        var p = (TcpConnector)obj;
 147        if (_timeout != p._timeout)
 48        {
 049            return false;
 50        }
 51
 152        if (!Network.addressEquals(_sourceAddr, p._sourceAddr))
 53        {
 054            return false;
 55        }
 56
 157        if (!_connectionId.Equals(p._connectionId, StringComparison.Ordinal))
 58        {
 059            return false;
 60        }
 61
 162        return _addr.Equals(p._addr);
 63    }
 64
 165    public override string ToString() => Network.addrToString(_proxy == null ? _addr : _proxy.getAddress());
 66
 67    public override int GetHashCode()
 68    {
 169        var hash = new HashCode();
 170        hash.Add(_addr);
 171        if (_sourceAddr is not null)
 72        {
 073            hash.Add(_sourceAddr);
 74        }
 175        hash.Add(_timeout);
 176        hash.Add(_connectionId);
 177        return hash.ToHashCode();
 78    }
 79
 80    private readonly ProtocolInstance _instance;
 81    private readonly EndPoint _addr;
 82    private readonly NetworkProxy _proxy;
 83    private readonly EndPoint _sourceAddr;
 84    private readonly int _timeout;
 85    private readonly string _connectionId;
 86    private readonly TcpBufSize _bufSize;
 87}