public void SSHRecoverNullConnection() { using (var c = new SSHRecoveringConnection(() => (ISSHConnection)null)) { c.ExecuteLinuxCommand("ls"); } }
public void SSHRecoverUsername() { using (var c = new SSHRecoveringConnection(() => new dummyConnection())) { Assert.AreEqual("myname", c.UserName); } }
public void SSHRecoverFailsConnectionSSHConnectionDroppedException() { var maker = new dummyConnectionMaker(failExecuteCommandForNTimes: 1, genException: () => new SSHConnectionDroppedException()); using (var c = new SSHRecoveringConnection(() => maker.Execute())) { c.RetryWaitPeriod = TimeSpan.FromMilliseconds(5); c.ExecuteLinuxCommand("ls"); Assert.AreEqual(3, dummyConnection.CalledExecuteLinuxCommand); } Assert.AreEqual(2, dummyConnection.DisposedCalled); }
public void SSHRecoverRegularConnection() { var maker = new dummyConnectionMaker(); using (var c = new SSHRecoveringConnection(() => maker.Execute())) { Assert.AreEqual(0, dummyConnection.DisposedCalled); c.ExecuteLinuxCommand("ls"); Assert.AreEqual(2, dummyConnection.CalledExecuteLinuxCommand); } Assert.AreEqual(1, dummyConnection.DisposedCalled); }
public void SSHRecoverNoRecover() { var maker = new dummyConnectionMaker(failExecuteCommandForNTimes: 1); using (var c = new SSHRecoveringConnection(() => maker.Execute())) { c.RetryWaitPeriod = TimeSpan.FromMilliseconds(1); using (var blocker = c.EnterNoRecoverRegion()) { c.ExecuteLinuxCommand("ls"); } } Assert.AreEqual(1, dummyConnection.DisposedCalled); Assert.AreEqual(1, dummyConnection.CTorCalls); }
public void SSHRecoverMakeSureCommandRetriedOnException() { var maker = new dummyConnectionMaker(failExecuteCommandForNTimes: 1); using (var c = new SSHRecoveringConnection(() => maker.Execute())) { c.RetryWaitPeriod = TimeSpan.FromMilliseconds(5); try { c.ExecuteLinuxCommand("ls"); } catch { } Assert.AreEqual(2, dummyConnection.ListOfCommands.Count()); Assert.AreEqual("ls", dummyConnection.ListOfCommands[0]); } Assert.AreEqual(2, dummyConnection.DisposedCalled); }