Esempio n. 1
0
        public async Task TestIcpIpConectToServerWhenNoServerIsRunningAsync()
        {
            using var tcpIp = new TcpIpConnectivity(port: 12345);
            var ex = await Assert.ThrowsAnyAsync <SocketException>(async() => await tcpIp.ConnectToServerAsync(numTimesToRetry: 2, delayMillis: 50));

            XAssert.IsNotNull(ex);
        }
 private async Task WithClient(TcpIpConnectivity tcpIpProvider, Func <NetworkStream, Task> action)
 {
     using (var tcpClient = await tcpIpProvider.ConnectToServerAsync())
         using (var stream = tcpClient.GetStream())
         {
             await action(stream);
         }
 }
 private async Task AssertPingServerFromNewClient(TcpIpConnectivity tcpIpProvider)
 {
     using (var tcpClient = await tcpIpProvider.ConnectToServerAsync())
         using (var stream = tcpClient.GetStream())
         {
             await AssertPingServer(stream);
         }
 }
 private async Task WithSetup(string testName, Func <MultiplexingClient, Socket, Task> testAction)
 {
     using (var tcpConnectivity = new TcpIpConnectivity(Utils.GetUnusedPortNumber()))
     {
         var serverSocketTask = Task.Run(() => tcpConnectivity.AcceptClientAsync(CancellationToken.None));
         using (var tcpClient = await tcpConnectivity.ConnectToServerAsync())
             using (var serverSocket = await serverSocketTask)
             {
                 var client = new MultiplexingClient(ClientConfigWithLogger(testName), tcpClient.GetStream());
                 await testAction(client, serverSocket);
             }
     }
 }