예제 #1
0
        public async Task SendCommandAsync_Should_Send_Data_And_Read_Response(int readBufferSize)
        {
            int port = new Random().Next(55000, 56000);

            ClamAvServerMock clamAvServerMock = new ClamAvServerMock(port);

            try
            {
                clamAvServerMock.Start(() => "PONG");

                using TcpSocketClient client = new TcpSocketClient(new ClamAvSettings("127.0.0.1", port, readBufferSize), NullLogger <TcpSocketClient> .Instance);
                await client.ConnectAsync().ConfigureAwait(false);

                string result = await client.SendCommandAsync(new PingCommand()).ConfigureAwait(false);

                result.Should().Be("PONG");
            }
            finally
            {
                clamAvServerMock.Stop();
            }
        }