public async Task TestConnect() { using QuicListener listener = CreateQuicListener(); listener.Start(); IPEndPoint listenEndPoint = listener.ListenEndPoint; using QuicConnection clientConnection = CreateQuicConnection(listenEndPoint); Assert.False(clientConnection.Connected); Assert.Equal(listenEndPoint, clientConnection.RemoteEndPoint); ValueTask connectTask = clientConnection.ConnectAsync(); QuicConnection serverConnection = await listener.AcceptConnectionAsync(); await connectTask; Assert.True(clientConnection.Connected); Assert.True(serverConnection.Connected); Assert.Equal(listenEndPoint, serverConnection.LocalEndPoint); Assert.Equal(listenEndPoint, clientConnection.RemoteEndPoint); Assert.Equal(clientConnection.LocalEndPoint, serverConnection.RemoteEndPoint); Assert.Equal(ApplicationProtocol.ToString(), clientConnection.NegotiatedApplicationProtocol.ToString()); Assert.Equal(ApplicationProtocol.ToString(), serverConnection.NegotiatedApplicationProtocol.ToString()); }
public async Task TestConnect() { await using QuicListener listener = await CreateQuicListener(); ValueTask <QuicConnection> connectTask = CreateQuicConnection(listener.LocalEndPoint); ValueTask <QuicConnection> acceptTask = listener.AcceptConnectionAsync(); await new Task[] { connectTask.AsTask(), acceptTask.AsTask() }.WhenAllOrAnyFailed(PassingTestTimeoutMilliseconds); await using QuicConnection serverConnection = acceptTask.Result; await using QuicConnection clientConnection = connectTask.Result; Assert.Equal(listener.LocalEndPoint, serverConnection.LocalEndPoint); Assert.Equal(listener.LocalEndPoint, clientConnection.RemoteEndPoint); Assert.Equal(clientConnection.LocalEndPoint, serverConnection.RemoteEndPoint); Assert.Equal(ApplicationProtocol.ToString(), clientConnection.NegotiatedApplicationProtocol.ToString()); Assert.Equal(ApplicationProtocol.ToString(), serverConnection.NegotiatedApplicationProtocol.ToString()); }