private void SetUp(object sender, PreWebTestEventArgs e)
 {
     try
     {
         MTApiFunctionalities mtApi = new MTApiFunctionalities();
         JObject userInfo           = mtApi.GenerateUserInfo();
         username = userInfo["username"].ToString();
         password = userInfo["password"].ToString();
         email    = userInfo["email"].ToString();
         HttpWebResponse httpResCreate = mtApi.CreateUser(mtUrl, username, password, email);
         httpResCreate.Close();
         HttpWebResponse httpResLogin      = mtApi.LoginUser(mtUrl, username, password);
         JObject         jsonResponseLogin = mtApi.JsonParseHttpRes(httpResLogin);
         userId = jsonResponseLogin["id"].ToString();
         httpResLogin.Close();
         HttpWebResponse httpResAdminLogin      = mtApi.LoginUser(mtUrl, adminUsername, adminPassword);
         JObject         jsonResponseAdminLogin = mtApi.JsonParseHttpRes(httpResAdminLogin);
         adminLoginToken = jsonResponseAdminLogin["token"].ToString();
         httpResAdminLogin.Close();
     }
     catch (WebException webExc)
     {
         Stop();                           // Stop test on exception
         Outcome           = Outcome.Fail; // Fail web test due to exception
         this.PostWebTest += TearDown;     // Add TearDown to make sure if user exists, it gets deleted
     }
 }
Beispiel #2
0
 public void SetUp(object sender, PreWebTestEventArgs e)
 {
     try
     {
         MTApiFunctionalities mtApi = new MTApiFunctionalities();
         JObject userInfo           = mtApi.GenerateUserInfo();
         username = userInfo["username"].ToString();
         password = userInfo["password"].ToString();
         email    = userInfo["email"].ToString();
     }
     catch (WebException webExc)
     {
         Stop();                 // Stop test on exception
         Outcome = Outcome.Fail; // Fail web test due to exception
     }
 }
 private void SetUp(object sender, PreWebTestEventArgs e)
 {
     try
     {
         MTApiFunctionalities mtApi = new MTApiFunctionalities();
         JObject userInfo           = mtApi.GenerateUserInfo();
         username = userInfo["username"].ToString();
         password = userInfo["password"].ToString();
         email    = userInfo["email"].ToString();
         HttpWebResponse httpResCreate = mtApi.CreateUser(mtUrl, username, password, email);
         JObject         jsonResponse  = mtApi.JsonParseHttpRes(httpResCreate);
         userId = jsonResponse["id"].ToString();
         httpResCreate.Close();
     }
     catch (WebException webExc)
     {
         Stop();                 // Stop test on exception
         Outcome = Outcome.Fail; // Fail web test due to exception
     }
 }