Advertisement
Guest User

Untitled

a guest
May 13th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. public interface ITestTransactionTimer : IDisposable { }
  2.  
  3. public class TestTransactionTimer : ITestTransactionTimer
  4. {
  5. public TestContext TestContext { get; private set; }
  6. public string TransactionName { get; private set; }
  7.  
  8. public TestTransactionTimer(TestContext testContext, string transactionName)
  9. {
  10. this.TestContext = testContext;
  11. this.TransactionName = transactionName;
  12.  
  13. this.TestContext.BeginTimer(this.TransactionName);
  14. }
  15.  
  16. public void Dispose()
  17. {
  18. this.TestContext.EndTimer(this.TransactionName);
  19. }
  20. }
  21.  
  22. public class NoOpTestTransactionTimer : ITestTransactionTimer
  23. {
  24. public void Dispose() { }
  25. }
  26. protected ITestTransactionTimer LogTransaction(string transactionName)
  27. {
  28. if ((null == this.TestContext) || !this.TestContext.Properties.Contains("$LoadTestUserContext"))
  29. {
  30. return new NoOpTestTransactionTimer();
  31. }
  32. return new TestTransactionTimer(this.TestContext, transactionName);
  33. }
  34.  
  35.  
  36. private TestContext testContextInstance;
  37. public TestContext TestContext
  38. {
  39. get { return testContextInstance; }
  40. set { testContextInstance = value; }
  41. }
  42.  
  43. //starting User Session
  44. [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "C:\Path\Data.csv", "Data#csv", DataAccessMethod.Sequential), DeploymentItem("C:\Path\Data.csv"), TestMethod]
  45. public void smokeTest()
  46. {
  47. sUserName = "domain\"+TestContext.DataRow["user"].ToString();
  48. sPassword = TestContext.DataRow["password"].ToString();
  49. prospectClientId = TestContext.DataRow["prospectClientId"].ToString();
  50. accountNumber = TestContext.DataRow["accountNumber"].ToString();
  51. correlationId = "startUserSession - " + obj.ToString();
  52.  
  53. // Start User Session
  54. using (this.LogTransaction("t1_startUserSession"))
  55. {
  56. ChannelFactory<IAppShellService> cfsus = null;
  57. try
  58. {
  59. using (ChannelBuilder.mPContext(ref appShellServiceClient, "IAppShellService", sUserName, sPassword, 0, null, correlationId, false, effectiveDate, ref cfsus))
  60. {
  61. var userSessionResult = appShellServiceClient.StartUserSession();
  62. }
  63. }
  64. catch (Exception ex)
  65. {
  66. Console.WriteLine(ex);
  67. }
  68. finally
  69. {
  70. cfsus.Close();
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement