public async Task Throws_On_Timeout()
        {
            var connector = new TransportConnector(new ConnectParameters {
                TransportParameters = _droppingEndpoint,
                ConnectTimeout      = TimeSpan.FromSeconds(1)
            }, new NullLogger <TransportConnector>());
            var connectTask = connector.ConnectAsync();

            // Connect should throw
            await Assert.ThrowsAsync <TimeoutException>(() => connectTask);
        }
        public async Task Connects_Successfully()
        {
            var connector = new TransportConnector(new ConnectParameters {
                TransportParameters = _testEndpoint,
                ConnectTimeout      = Timeout.InfiniteTimeSpan
            }, new NullLogger <TransportConnector>());
            var connectTask = connector.ConnectAsync();

            // Accept client
            using var client = await _testServer.AcceptTcpClientAsync();

            // Connect should succeed
            (await connectTask).Dispose();
        }
        public async Task Throws_On_Cancel()
        {
            using var cts = new CancellationTokenSource();

            var connector = new TransportConnector(new ConnectParameters {
                TransportParameters = _droppingEndpoint,
                ConnectTimeout      = Timeout.InfiniteTimeSpan
            }, new NullLogger <TransportConnector>());
            var connectTask = connector.ConnectAsync(cts.Token);

            // Task should still be alive
            Assert.False(connectTask.IsCompleted);

            // Cancel connect
            cts.CancelAfter(100);

            // Connect should throw
            await Assert.ThrowsAnyAsync <OperationCanceledException>(() => connectTask);
        }