public void TestAid() { var session = new MockTaskSession(); session.VerifyStart(); session.VerifyCommand(() => session.Enter(), "Enter()"); session.VerifyCommand(() => session.Clear(), "Clear()"); session.VerifyCommand(() => session.PF(1), "PF(1)"); session.VerifyCommand(() => session.PF(2), "PF(2)"); session.VerifyCommand(() => session.PA(1), "PA(1)"); session.VerifyCommand(() => session.PA(2), "PA(2)"); // Force some exceptions. Assert.Throws <ArgumentOutOfRangeException>(() => session.PF(0)); Assert.Throws <ArgumentOutOfRangeException>(() => session.PF(25)); Assert.Throws <ArgumentOutOfRangeException>(() => session.PA(0)); Assert.Throws <ArgumentOutOfRangeException>(() => session.PA(4)); session.ExceptionMode = true; session.AllFail = true; Assert.Throws <X3270ifCommandException>(() => session.Enter()); Assert.Throws <X3270ifCommandException>(() => session.Clear()); Assert.Throws <X3270ifCommandException>(() => session.PF(1)); Assert.Throws <X3270ifCommandException>(() => session.PA(1)); session.Close(); }
public void TestStatusField() { var session = new MockTaskSession(); // Test StatusField exception when not running. Assert.Throws <InvalidOperationException>(() => session.StatusField(StatusLineField.Formatting)); var startResult = session.Start(); Assert.AreEqual(true, startResult.Success); // Test ordinary StatusField. Assert.AreEqual("F", session.StatusField(StatusLineField.Formatting)); // Test origin-based StatusField. Assert.AreEqual("0", session.StatusField(StatusLineField.CursorRow)); Assert.AreEqual("0", session.StatusField(StatusLineField.CursorColumn)); session.Close(); // Test origin-based StatusField with 1-origin. session = new MockTaskSession(new MockTaskConfig { Origin = 1 }); session.Start(); Assert.AreEqual("1", session.StatusField(StatusLineField.CursorRow)); Assert.AreEqual("1", session.StatusField(StatusLineField.CursorColumn)); // Exercise HostConnected (based on the status line). Assert.AreEqual(true, session.HostConnected); // Change that. session.Connected = false; // (Have to run a dummy command to get a new prompt and change state.) session.Io("Query()"); Assert.AreEqual(false, session.HostConnected); // Now screen-modifying commands will fail. Assert.AreEqual(false, session.Enter().Success); // Now exception mode will fire, too. session.ExceptionMode = true; Assert.Throws <X3270ifCommandException>(() => session.Enter()); // Try requiring 3270 mode instead. session.Config.ModifyFail = ModifyFailType.Require3270; Assert.Throws <X3270ifCommandException>(() => session.Enter()); // And that normally, it's fine. session.Connected = true; session.Connect("bob"); Assert.DoesNotThrow(() => session.Enter()); session.Close(); }