Exemple #1
0
        private void TearDown(object sender, PostWebTestEventArgs e)
        {
            MTApiFunctionalities mtApi        = new MTApiFunctionalities();
            HttpWebResponse      httpResLogin = mtApi.LoginUser(mtUrl, username, password);
            JObject jsonResponse = mtApi.JsonParseHttpRes(httpResLogin);
            string  userId       = jsonResponse["id"].ToString();

            httpResLogin.Close();
            HttpWebResponse httpResAdminLogin      = mtApi.LoginUser(mtUrl, adminUsername, adminPassword); // Login as admin to get admin token to delete user
            JObject         jsonResponseAdminLogin = mtApi.JsonParseHttpRes(httpResAdminLogin);
            string          adminLoginToken        = jsonResponseAdminLogin["token"].ToString();

            httpResAdminLogin.Close();
            HttpWebResponse httpResDel = mtApi.DeleteUser(mtUrl, userId, adminLoginToken);

            httpResDel.Close();
        }
        private void TearDown(object sender, PostWebTestEventArgs e)
        {
            MTApiFunctionalities mtApi = new MTApiFunctionalities();

            if (string.IsNullOrEmpty(userId)) // When SetUp fails and didn't save userId
            {
                HttpWebResponse httpResLogin = mtApi.LoginUser(mtUrl, username, password);
                JObject         jsonResponse = mtApi.JsonParseHttpRes(httpResLogin);
                userId = jsonResponse["id"].ToString();
                httpResLogin.Close();
            }
            HttpWebResponse httpResAdminLogin      = mtApi.LoginUser(mtUrl, adminUsername, adminPassword); // Login as admin to get admin token to delete user
            JObject         jsonResponseAdminLogin = mtApi.JsonParseHttpRes(httpResAdminLogin);

            adminLoginToken = jsonResponseAdminLogin["token"].ToString();
            httpResAdminLogin.Close();
            HttpWebResponse httpResDel = mtApi.DeleteUser(mtUrl, userId, adminLoginToken);

            httpResDel.Close();
        }