public async Task ReceiveRawMessageNotConnectedSocketShouldReturnNull() { var peer = new SocketCommunicationManager(); Assert.IsNull(peer.ReceiveRawMessage()); Assert.IsNull(await peer.ReceiveRawMessageAsync(CancellationToken.None)); }
public void SocketThroughput1() { // Measure the throughput with socket communication v1 (SocketCommunicationManager) // implementation. var server = new SocketCommunicationManager(); var client = new SocketCommunicationManager(); var watch = new Stopwatch(); int port = server.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port; client.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)).Wait(); server.AcceptClientAsync().Wait(); server.WaitForClientConnection(1000); client.WaitForServerConnection(1000); var clientThread = new Thread(() => SendData2(client, watch)); clientThread.Start(); var dataReceived = 0; while (dataReceived < 65536 * 20000) { dataReceived += server.ReceiveRawMessage().Length; } watch.Stop(); clientThread.Join(); Assert.IsTrue(watch.Elapsed < TimeSpan.FromSeconds(4), "Elapsed: " + watch.Elapsed); }