public async Task SendMessageShouldReceiveAResponse() { // Arrange var channel = new FakeChannel(); var rconClient = RconClient.Create(channel); await rconClient.ConnectAsync(); // Act var response = await rconClient.ExecuteCommandAsync("test echo"); // Assert Assert.Equal("Command executed", response); }
public async Task CanceledResponseShouldDisconnectTheClient() { // Arrange var channel = new FakeChannel(); channel.CancelNextReponse(); var rconClient = RconClient.Create(channel); await rconClient.ConnectAsync(); var tcs = new TaskCompletionSource <bool>(); rconClient.ConnectionClosed += () => { tcs.SetResult(true); }; // Act Assert await Assert.ThrowsAsync <TaskCanceledException>(() => rconClient.ExecuteCommandAsync("test echo")); Assert.True(await tcs.Task); }