/// <summary> /// Just a scenario to test whether the adapter actually does something useful. /// This is helpful to try out the adapter without calling ct.exe, the conformance /// tester of NModel. /// </summary> /// <param name="args"></param> public static void Main(String[] args) { Session session = new Session(); string currentURL = "http://192.168.32.128/doStuff.php"; string currentUser = "******"; string currentPassword = "******"; string page = ""; page = session.getQuery(currentURL, ""); string queryString = "username="******"&" + "password=" + currentPassword; page = session.postQuery(currentURL, currentURL, queryString); Console.WriteLine(page); }
/// <summary> /// Just a scenario to test whether the adapter actually does something useful. /// This is helpful to try out the adapter without calling ct.exe, the conformance /// tester of NModel. /// </summary> /// <param name="args"></param> public static void Main(String[] args) { Session session = new Session(); string currentURL = "http://192.168.32.128/doStuff.php"; string currentUser = "******"; string currentPassword = "******"; string page = ""; page = session.getQuery(currentURL, ""); string queryString = "username="******"&" + "password=" + currentPassword; page = session.postQuery(currentURL, currentURL, queryString); Console.WriteLine(page); }
CompoundTerm IStepper.DoAction(CompoundTerm action) { Session session = null; Console.WriteLine(action.Name); switch (action.Name) { #region Initialization action. case "Initialize": initialize(); return(null); #endregion #region Login action case "Login_Start": string userName = ""; modelUserToRealUser.TryGetValue((string)((CompoundTerm)action[0])[0], out userName); //"OleBrumm" -> "user" string userPass = ""; switch ((string)((CompoundTerm)action[1])[0]) //Correct or Incorrect { case "Correct": userPass = realUserPassword[userName]; break; case "Incorrect": userPass = wrongPassword; break; default: throw new Exception("The password is neither correct nor incorrect!"); } session = getUserSession(userName); page = session.getQuery(currentURL, ""); string queryString = WebTestHelper.createLoginParams(userName, userPass); page = session.postQuery(currentURL, currentURL, queryString); LoginStatus status = LoginStatus.Success; if (WebTestHelper.loginFailed(page)) { status = LoginStatus.Failure; } return(Action.Create("Login_Finish", action[0], status)); case "Logout": modelUserToRealUser.TryGetValue((string)((CompoundTerm)action[0])[0], out userName); //"OleBrumm" -> "user" session = getUserSession(userName); session.getQuery(logOffURL, ""); resetUserSession(userName); return(null); #endregion #region ChangeNumber case "UpdateInt": modelUserToRealUser.TryGetValue((string)((CompoundTerm)action[0])[0], out userName); //"OleBrumm" -> "user" session = getUserSession(userName); session.getQuery(currentURL, "num=" + action[1].ToString()); return(null); case "ReadInt": modelUserToRealUser.TryGetValue((string)((CompoundTerm)action[0])[0], out userName); //"OleBrumm" -> "user" session = getUserSession(userName); page = session.getQuery(currentURL, ""); WebTestHelper.containsInt(page, (int)action[1]); return(null); #endregion default: throw new Exception("The action " + action.Name + " is undefined in the system adapter!"); } }