< Summary

Information
Class: IceRpc.Transports.Coloc.Internal.ColocServerTransport
Assembly: IceRpc.Transports.Coloc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Transports.Coloc/Internal/ColocServerTransport.cs
Tag: 1321_24790053727
Line coverage
87%
Covered lines: 28
Uncovered lines: 4
Coverable lines: 32
Total lines: 65
Line coverage: 87.5%
Branch coverage
80%
Covered branches: 8
Total branches: 10
Branch coverage: 80%
Method coverage
100%
Covered methods: 4
Fully covered methods: 3
Total methods: 4
Method coverage: 100%
Full method coverage: 75%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_DefaultName()100%11100%
Listen(...)80%111082.6%
OnDispose()100%11100%
.ctor(...)100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Transports.Coloc/Internal/ColocServerTransport.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Collections.Concurrent;
 4using System.Net.Security;
 5
 6namespace IceRpc.Transports.Coloc.Internal;
 7
 8/// <summary>Implements <see cref="IDuplexServerTransport" /> for the coloc transport.</summary>
 9internal class ColocServerTransport : IDuplexServerTransport
 10{
 11    /// <inheritdoc/>
 13012    public string DefaultName => ColocTransport.Name;
 13
 14    private readonly ConcurrentDictionary<(string Host, ushort Port), ColocListener> _listeners;
 15    private readonly ColocTransportOptions _options;
 16
 17    /// <inheritdoc/>
 18    public IListener<IDuplexConnection> Listen(
 19        TransportAddress transportAddress,
 20        DuplexConnectionOptions options,
 21        SslServerAuthenticationOptions? serverAuthenticationOptions)
 51822    {
 51823        if (serverAuthenticationOptions is not null)
 024        {
 025            throw new NotSupportedException("The Coloc server transport does not support SSL.");
 26        }
 27
 51828        if (transportAddress.TransportName is string name && name != DefaultName)
 029        {
 030            throw new NotSupportedException($"The Coloc server transport does not support transport '{name}'.");
 31        }
 32
 51833        if (transportAddress.Params.Count > 0)
 234        {
 235            throw new ArgumentException(
 236                "The transport address contains parameters that are not valid for the Coloc server transport.",
 237                nameof(transportAddress));
 38        }
 39
 51640        var key = (transportAddress.Host, transportAddress.Port);
 41
 51642        var listener = new ColocListener(
 51643            transportAddress,
 51644            onDispose: OnDispose,
 51645            colocTransportOptions: _options,
 51646            duplexConnectionOptions: options);
 47
 51648        if (!_listeners.TryAdd(key, listener))
 249        {
 250            throw new IceRpcException(IceRpcError.AddressInUse);
 51        }
 51452        return listener;
 53
 54        void OnDispose(ColocListener disposedListener) =>
 51455            _listeners.TryRemove(new KeyValuePair<(string, ushort), ColocListener>(key, disposedListener));
 51456    }
 57
 50958    internal ColocServerTransport(
 50959        ConcurrentDictionary<(string Host, ushort Port), ColocListener> listeners,
 50960        ColocTransportOptions options)
 50961    {
 50962        _listeners = listeners;
 50963        _options = options;
 50964    }
 65}