public void Connect_ZeroPort_ThrowsArgumentException() { var mockSocket = Substitute.For<ISymSocket>(); var session = new SymSession(mockSocket); Assert.Throws<ArgumentOutOfRangeException>( () => session.Connect("symitar", 0)); }
//------------------------------------------------------------------------ private void btnTest_Click(object sender, EventArgs e) { SymSession test = new SymSession(); try { if (!test.Connect(txtIP.Text, int.Parse(txtPort.Text))) { MessageBox.Show(test.error, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!test.AIXTest(txtUser.Text, txtPass.Text)) { MessageBox.Show(test.error, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception ex) { MessageBox.Show("Error During Login\n" + ex.Message, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } test.Disconnect(); MessageBox.Show("Server Connected Okay!", "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.None); }
public void Connect_ZeroPort_ThrowsArgumentException() { var mockSocket = Substitute.For <ISymSocket>(); var session = new SymSession(mockSocket); Assert.Throws <ArgumentOutOfRangeException>( () => session.Connect("symitar", 0)); }
private void AfterConnect() { var socketMock = Substitute.For <ISymSocket>(); socketMock.Connect().Returns(true); socketMock.Connected.Returns(true); _session = new SymSession(socketMock); _session.Connect("symitar", 23); }
public void Reconnect_CallsDisconnectAndConnect() { var socketMock = Substitute.For <ISymSocket>(); var session = new SymSession(socketMock, 10); session.Connect("symitar", 23); session.Reconnect(); socketMock.Received().Disconnect(); socketMock.Received().Connect("symitar", 23); }
private void Login() { while (!_session.LoggedIn) { _session.Disconnect(); _session.Connect("symitar", 23); _session.Login("jdeering", "h3dd0#mon", "083ch#ckb00k"); if (_session.LoggedIn) { responseBox.Text += @"Logged in"; responseBox.Text += "\n\n"; } } }
//======================================================================== public bool Connect() { if (Connection != null) { if (Connection.isLoggedIn) { return(true); } } Connection = new SymSession(); if (!Connection.Connect(Parent.IP, Parent.Port)) { return(false); } if (Connection.Login(Parent.AixUsr, Parent.AixPwd, SymDir, SymId) == false) { Connection.Disconnect(); Connection = null; return(false); } return(true); }
public void Connect_BlankServer_ThrowsArgumentException() { BeforeConnect(); Assert.Throws <ArgumentNullException>( () => _session.Connect("", 1)); }
private void AfterConnect() { var socketMock = Substitute.For<ISymSocket>(); socketMock.Connect().Returns(true); socketMock.Connected.Returns(true); _session = new SymSession(socketMock); _session.Connect("symitar", 23); }
public void Reconnect_CallsDisconnectAndConnect() { var socketMock = Substitute.For<ISymSocket>(); var session = new SymSession(socketMock, 10); session.Connect("symitar", 23); session.Reconnect(); socketMock.Received().Disconnect(); socketMock.Received().Connect("symitar", 23); }
//======================================================================== // sym Connections //======================================================================== public static SymSession TrySymNewConnect(SymInst inst) { SymSession session = new SymSession(); bool prompt = false; string user = inst.Parent.AixUsr; string pass = inst.Parent.AixPwd; string id = inst.SymId; if (user == "") { prompt = true; } if (pass == "") { prompt = true; } if (id == "") { prompt = true; } bool success = false; if (!prompt) { success = session.Connect(inst.Parent.IP, inst.Parent.Port); if (success) { success = session.Login(user, pass, inst.SymDir, id); } while (!success) { if (MessageBox.Show("Error Connecting to Sym\nRetry?", "PwrIDE", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No) { break; } success = session.Connect(inst.Parent.IP, inst.Parent.Port); if (success) { success = session.Login(user, pass, inst.SymDir, id); } } if (!success) { return(null); } return(session); } while (!success) { frmLogin login = new frmLogin(inst.Parent.IP, inst.SymDir, user, pass, id); if (login.ShowDialog(MainForm) == DialogResult.Cancel) { break; } inst.Parent.AixUsr = user = login.User; inst.Parent.AixPwd = pass = login.Pass; inst.SymId = id = login.ID; login.Dispose(); success = inst.Connect(); if (success) { success = session.Login(user, pass, inst.SymDir, id); } if (!success) { if (MessageBox.Show("Error Connecting to Sym\nRetry?", "PwrIDE", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No) { break; } } } if (!success) { return(null); } return(session); }
//------------------------------------------------------------------------ private void btnTest_Click(object sender, EventArgs e) { SymSession test = new SymSession(); try { if (!test.Connect(Server.IP, Server.Port)) { MessageBox.Show(test.error, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string aixPwd = Server.AixPwd; if (aixPwd.Trim().Length == 0) { InputBox inp = new InputBox("Test Sym Connection", "Please Enter AIX Password for Server \"" + Server.Alias + "\".", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } aixPwd = inp.Input; inp.Dispose(); } bool retry = true; bool result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text); while (retry && (!result)) { retry = false; if (result == false) { if (test.error == "Invalid AIX Login") { InputBox inp = new InputBox("Test Sym Connection", "Invalid AIX Login.\nPlease Re-Enter or Cancel (ESC).", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } aixPwd = inp.Input; inp.Dispose(); result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text, 1); retry = true; } else if (test.error == "Invalid Sym User") { InputBox inp = new InputBox("Test Sym Connection", "Invalid Sym User ID.\nPlease Re-Enter or Cancel (ESC).", "", true); if (inp.ShowDialog(this) == DialogResult.Cancel) { return; } txtID.Text = inp.Input; inp.Dispose(); result = test.Login(Server.AixUsr, aixPwd, txtSym.Text, txtID.Text, 2); retry = true; } else { retry = (MessageBox.Show("Error Connecting to Sym\nError: " + test.error + "\n\nRetry?", "Sym Connection Test", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes); } if ((!retry) && (!result)) { test.Disconnect(); return; } } } } catch (Exception ex) { MessageBox.Show("Error During Login Test\n" + ex.Message, "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } test.Disconnect(); MessageBox.Show("Sym Connected Okay!", "PwrIDE", MessageBoxButtons.OK, MessageBoxIcon.None); }