public void testIsAlive() { VistaPoolConnection cxn = (VistaPoolConnection)AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant("PVISTA")).getConnection(_localSource.CxnSource); cxn.connect(); login(cxn); cxn.setTimeout(new TimeSpan(0, 0, 1)); // set this low - one second - so the test can run quickly Assert.IsTrue(cxn.isAlive()); System.Threading.Thread.Sleep(500); // sleep for less than timeout \ // \ cxn.heartbeat(); Assert.IsTrue(cxn.isAlive()); System.Threading.Thread.Sleep(500); // sleep for less than timeout -- These three add up to more than timeout cxn.heartbeat(); Assert.IsTrue(cxn.isAlive()); // / System.Threading.Thread.Sleep(500); // sleep for less than timeout / cxn.heartbeat(); Assert.IsTrue(cxn.isAlive()); System.Threading.Thread.Sleep(1100);// sleep for more than timeout Assert.IsFalse(cxn.isAlive()); Assert.IsFalse(cxn.IsConnected); try { new VistaPatientDao(cxn).match("m1234"); Assert.Fail("Uh-oh! Previous line should have thrown exception!"); } catch (Exception) { // cool! } }