public static IEndPoint CreateSubstitute() { IEndPoint endpoint = Substitute.For <IEndPoint>(); endpoint.CreateCopy().Returns(endpoint); return(endpoint); }
private Connection CreateNewConnection(IEndPoint newEndPoint) { // create copy of endpoint for this connection // this is so that we can re-use the endpoint (reduces alloc) for receive and not worry about changing internal data needed for each connection var endPoint = newEndPoint?.CreateCopy(); var connection = new Connection(this, endPoint, _dataHandler, _config, _maxPacketSize, _time, _bufferPool, _logger, _metrics); connection.SetReceiveTime(); _connections.Add(endPoint, connection); return(connection); }