public static void PostWebTestEvent(object sender, PostWebTestEventArgs e, DataTable _DTTransactionDetails) { if (vsoTransactionContext.IsSaveTransactionInAzure) { string testdetailID = e.WebTest.Context["TestDetailID"].ToString(); string testcaseID = e.WebTest.Context["TestCaseId"].ToString(); string agentId = e.WebTest.Context["AgentID"].ToString(); string loadtestrunID = e.WebTest.Context["LoadTestrunID"].ToString(); Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestUserContext loadtestusercontext = (Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestUserContext)e.WebTest.Context["$LoadTestUserContext"]; if (!loadtestusercontext.ContainsKey(testcaseID.ToString() + "_" + e.WebTest.Context.WebTestUserId.ToString())) { loadtestusercontext.Add(testcaseID.ToString() + "_" + e.WebTest.Context.WebTestUserId.ToString(), _DTTransactionDetails.Copy()); } else { loadtestusercontext[testcaseID.ToString() + "_" + e.WebTest.Context.WebTestUserId.ToString()] = _DTTransactionDetails.Copy(); } string basicTestData = testdetailID.ToString() + "|" + testcaseID.ToString() + "|" + e.WebTest.Context.WebTestUserId.ToString() + "|" + agentId.ToString() + "|" + loadtestrunID.ToString(); if (!loadtestusercontext.ContainsKey(testcaseID.ToString() + "_T_" + e.WebTest.Context.WebTestUserId.ToString())) { loadtestusercontext.Add(testcaseID.ToString() + "_T_" + e.WebTest.Context.WebTestUserId.ToString(), basicTestData); } else { loadtestusercontext[testcaseID.ToString() + "_T_" + e.WebTest.Context.WebTestUserId.ToString()] = basicTestData; } } }
public override void PostWebTest(object sender, PostWebTestEventArgs e) { //base.PostWebTest(sender, e); SWatch.Stop(); var elapsedtimeinms = SWatch.ElapsedMilliseconds; if (this.maximumTesttime > 0) { if (elapsedtimeinms > maximumTesttime) { e.WebTest.Outcome = Outcome.Fail; } } }
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(); }
public override void PostWebTest(object sender, PostWebTestEventArgs e) { base.PostWebTest(sender, e); }
private void OnPostWebTest(object sender, PostWebTestEventArgs postWebTestEventArgs) { try { CleanUp(); testRequests = null; } catch (Exception ex) { postWebTestEventArgs.WebTest.Outcome = Outcome.Fail; postWebTestEventArgs.WebTest.AddCommentToResult("Cleanup failed: " + ex.ToString()); } }
public override void PostWebTest(object sender, PostWebTestEventArgs e) { }
public override void PostWebTest(object sender, PostWebTestEventArgs e) { // TODO: Add code to execute after the test. }
public override void PostWebTest(object sender, PostWebTestEventArgs e) { //MessageBox.Show("Web Test Ending ..."); }
public override void PostWebTest(object sender, PostWebTestEventArgs e) { base.PostWebTest(sender, e); if (e.WebTest.Context.ContainsKey("$LoadTestUserContext")) { LoadTestUserContext loadTestUserContext = e.WebTest.Context["$LoadTestUserContext"] as LoadTestUserContext; if (e.WebTest.Context[Constants.Context_ReuseConvId].ToString().Equals("true", StringComparison.OrdinalIgnoreCase)) { if (e.WebTest.Context.ContainsKey(Constants.Context_ConvId)) { loadTestUserContext[Constants.Context_ConvId] = e.WebTest.Context[Constants.Context_ConvId].ToString(); } } if (e.WebTest.Context[Constants.Context_ReuseUserId].ToString().Equals("true", StringComparison.OrdinalIgnoreCase)) { if (e.WebTest.Context.ContainsKey(Constants.Context_UserId)) { loadTestUserContext[Constants.Context_UserId] = e.WebTest.Context[Constants.Context_UserId].ToString(); } } if (e.WebTest.Context.ContainsKey(Constants.Context_AccessToken)) { loadTestUserContext[Constants.Context_AccessToken] = e.WebTest.Context[Constants.Context_AccessToken].ToString(); } } else { if (e.WebTest.Context[Constants.Context_ReuseConvId].ToString().Equals("true", StringComparison.OrdinalIgnoreCase)) { Helpers.ConvId = e.WebTest.Context[Constants.Context_ConvId].ToString(); } Helpers.AccessToken = e.WebTest.Context[Constants.Context_AccessToken].ToString(); } string testStatus = e.WebTest.Context.ContainsKey(Constants.Context_TestStatus) ? e.WebTest.Context[Constants.Context_TestStatus].ToString() : "false"; if (!e.WebTest.Context.ContainsKey(Constants.Context_MessagePostedToBot)) { e.WebTest.Context[Constants.Context_ActualResult] = "Not able to submit message"; testStatus = "false"; } string convId = e.WebTest.Context.ContainsKey(Constants.Context_ConvId) ? e.WebTest.Context[Constants.Context_ConvId].ToString() : string.Empty; if (string.IsNullOrEmpty(convId)) { convId = "conversation couldn't be created"; } if (e.WebTest.Context.ContainsKey(Constants.Context_MessageId) && !string.IsNullOrEmpty(e.WebTest.Context[Constants.Context_MessageId].ToString())) { string utterance = e.WebTest.Context[Constants.Context_Utterance].ToString(); string luisQnA = e.WebTest.Context[Constants.Context_LuisQnA].ToString(); string businessArea = e.WebTest.Context[Constants.Context_BusinessArea].ToString(); string actual = e.WebTest.Context.ContainsKey(Constants.Context_ActualResult) ? e.WebTest.Context[Constants.Context_ActualResult].ToString() : string.Empty; string testMatch = e.WebTest.Context.ContainsKey(Constants.Context_TestMatch) ? e.WebTest.Context[Constants.Context_TestMatch].ToString() : "false"; string duration = e.WebTest.Context.ContainsKey(Constants.Context_Duration) ? e.WebTest.Context[Constants.Context_Duration].ToString() : "0"; string message = e.WebTest.Context.ContainsKey(Constants.Context_TestStatusMessage) ? e.WebTest.Context[Constants.Context_TestStatusMessage].ToString() : string.Empty; string activityCount = e.WebTest.Context.ContainsKey(Constants.Context_ActivityCount) ? e.WebTest.Context[Constants.Context_ActivityCount].ToString() : "0"; string messageId = e.WebTest.Context.ContainsKey(Constants.Context_MessageId) ? e.WebTest.Context[Constants.Context_MessageId].ToString() : "Not able to submit messsage"; string userId = e.WebTest.Context.ContainsKey(Constants.Context_UserId) ? e.WebTest.Context[Constants.Context_UserId].ToString() : "User XX"; if (!string.IsNullOrEmpty(message)) { actual = message; } e.WebTest.Outcome = testStatus.Equals("true", StringComparison.OrdinalIgnoreCase) ? Outcome.Pass : Outcome.Fail; ReportHelper.WriteLog(convId, utterance, messageId, userId, string.Empty, actual, testStatus, testMatch, duration, activityCount, businessArea, luisQnA); } }