public void TestCommandFail(bool useUTF8) { var server = new RemoteConServer(IPAddress.Any, 27015); server.StartListening(); server.UseUTF8 = useUTF8; string commandResult = null; using (var waitEvent = new AutoResetEvent(false)) { var client = new RemoteConClient(); client.UseUTF8 = useUTF8; client.OnAuthResult += success => { client.SendCommand("testing", result => { commandResult = result; client.Disconnect(); server.StopListening(); waitEvent.Set(); }); }; client.Connect("127.0.0.1", 27015); client.Authenticate("changeme"); waitEvent.WaitOne(); } Assert.Contains("Invalid command", commandResult); }
public void TestAuthSuccess(bool useUTF8) { var server = new RemoteConServer(IPAddress.Any, 27015); server.UseUTF8 = useUTF8; server.StartListening(); bool authResult = false; using (var waitEvent = new AutoResetEvent(false)) { var client = new RemoteConClient(); client.UseUTF8 = useUTF8; client.OnAuthResult += success => { authResult = success; client.Disconnect(); server.StopListening(); waitEvent.Set(); }; client.Connect("127.0.0.1", 27015); client.Authenticate("changeme"); waitEvent.WaitOne(); } Assert.True(authResult); }
public void TestCommandSuccess(bool useUTF8) { var server = new RemoteConServer(IPAddress.Any, 27015); server.CommandManager.Add("hello", "Replies with world", (command, args) => "world"); server.UseUTF8 = true; server.StartListening(); string commandResult = null; using (var waitEvent = new AutoResetEvent(false)) { var client = new RemoteConClient(); client.UseUTF8 = useUTF8; client.OnAuthResult += success => { client.SendCommand("hello", result => { commandResult = result; client.Disconnect(); server.StopListening(); waitEvent.Set(); }); }; client.Connect("127.0.0.1", 27015); client.Authenticate("changeme"); waitEvent.WaitOne(); } Assert.Contains("world", commandResult); }
public void TestAuthFail(bool useUtf8) { var server = new RemoteConServer(IPAddress.Any, 27015) { UseUtf8 = useUtf8 }; server.StartListening(); var authResult = true; var waitEvent = new AutoResetEvent(false); var client = new RemoteConClient { UseUtf8 = useUtf8 }; client.OnAuthResult += success => { authResult = success; client.Disconnect(); server.StopListening(); waitEvent.Set(); }; client.Connect("127.0.0.1", 27015); client.Authenticate("unitfail"); waitEvent.WaitOne(); Assert.False(authResult); }
public void TestAuthFail() { var server = new RemoteConServer(IPAddress.Any, 27015); server.StartListening(); var client = new RemoteConClient(); client.OnAuthResult += success => { Assert.False(success); client.Disconnect(); server.StopListening(); }; client.Connect("127.0.0.1", 27015); client.Authenticate("unitfail"); }
public void TestCommandSuccess() { var server = new RemoteConServer(IPAddress.Any, 27015); server.StartListening(); var client = new RemoteConClient(); client.OnAuthResult += success => { //Assert.True(success); client.SendCommand("hello", result => { Assert.Contains("world", result); client.Disconnect(); server.StopListening(); }); }; client.Connect("127.0.0.1", 27015); client.Authenticate("changeme"); }