public void ClientDisconnectsServer_ServerOnClientDisconnectCalled() { //Arrange //Create a second client ObjectTransport clientObjectTransport2 = TestObjectTransportFactory.CreateNewObjectTransport(Client2); clientObjectTransport2.Start("127.0.0.1", Server.LocalPort); //Wait for the connection to have been made Utilities.WaitFor(() => serverObjectTransport.GetConnectedClients().Count() == 2); //Act //disconnect the server from the client Client1ObjectTransport.DisconnectClient(); Utilities.WaitFor(() => ServerOnDisconnectClients.Count == 1); //Assert //Ensure that the client record was disconnect from the server Assert.AreEqual(1, serverObjectTransport.GetConnectedClients().Count()); //Esnure that the client who disconnected from the server was the one that we called disconect Assert.AreEqual(ServerOnDisconnectClients.First().Port, Client1.LocalPort); }