public void testRecover() { // recover restarts server if it's needed // and reconnects Client client = new Client(); FunctionalityTests.killServer(); client.recover(); Assert.IsTrue(client.is_connected, "Client did not restart/reconnect properly."); }
public void testEnsureServerRuns() { Client client = new Client(); // ensure no server runs FunctionalityTests.killServer(); while (Process.GetProcessesByName("Server").Length > 0) { Thread.Sleep(10); } client.ensureServerRuns(); Assert.IsTrue(Process.GetProcessesByName("Server").Length > 0, "Server process does not exist after calling 'ensureServerRuns'."); }
public void testRequestStockTransfer() { FunctionalityTests.killServer(); Client client = new Client(); client.connect(); // spawn another client and ensure he doesn't have the stock Client another_client = new Client(); another_client.connect(); Constants.arbitraryResponseWait(); Console.Write($"testRequestStockTransfer another_client.id = {another_client.id}, another_client.stock_holder_id = {another_client.stock_holder}"); Assert.IsFalse(another_client.has_stock, "another_client also has stock (after connecting), this shouldn't be the case."); // ensure stock is transfered client.requestStockTransfer(another_client.id); Constants.arbitraryResponseWait(); Assert.IsTrue(another_client.has_stock, "another_client did not receive the stock after transfer."); Assert.IsFalse(client.has_stock, "client did not lose the stock after giving it."); }