PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/V2.2/trunk/Quickstarts/EventAggregation/EventAggregation.Tests.AcceptanceTest/EventAggregation.Tests.AcceptanceTest/Silverlight/EventAggregation.Silverlight.Test.cs

#
C# | 156 lines | 87 code | 13 blank | 56 comment | 3 complexity | f6240b0c6cea48ffbd48d381887c515d MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using System.Text;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using Microsoft.VisualStudio.TestTools.UnitTesting;
  22. using System.Windows.Automation;
  23. using System.Windows.Automation.Peers;
  24. using System.Windows.Automation.Text;
  25. using System.Windows.Automation.Provider;
  26. using AcceptanceTestLibrary.Common;
  27. using AcceptanceTestLibrary.ApplicationHelper;
  28. using System.IO;
  29. using AcceptanceTestLibrary.Common.Silverlight;
  30. using EventAggregation.Tests.AcceptanceTest.TestEntities.Page;
  31. using EventAggregation.Tests.AcceptanceTest.TestEntities.Assertion;
  32. using AcceptanceTestLibrary.TestEntityBase;
  33. using System.Reflection;
  34. using System.Threading;
  35. namespace EventAggregation.Tests.AcceptanceTest.Silverlight
  36. {
  37. /// <summary>
  38. /// Summary description for EventAggregation
  39. /// </summary>
  40. #if DEBUG
  41. [DeploymentItem(@"..\Silverlight\bin\Debug", "SL")]
  42. [DeploymentItem(@".\EventAggregation.Tests.AcceptanceTest\bin\Debug")]
  43. #else
  44. [DeploymentItem(@"..\Silverlight\bin\Release", "SL")]
  45. [DeploymentItem(@".\EventAggregation.Tests.AcceptanceTest\bin\Release")]
  46. #endif
  47. [TestClass]
  48. public class EventAggregation_Silverlight_Tests : FixtureBase<SilverlightAppLauncher>
  49. {
  50. private const int BACKTRACKLENGTH = 4;
  51. #region Additional test attributes
  52. // Use TestInitialize to run code before running each test
  53. [TestInitialize()]
  54. public void MyTestInitialize()
  55. {
  56. string currentOutputPath = (new System.IO.DirectoryInfo(Assembly.GetExecutingAssembly().Location)).Parent.FullName;
  57. EventAggregationPage<SilverlightAppLauncher>.Window = base.LaunchApplication(currentOutputPath + GetSilverlightApplication(), GetBrowserTitle())[0];
  58. Thread.Sleep(5000);
  59. }
  60. // Use TestCleanup to run code after each test has run
  61. [TestCleanup()]
  62. public void MyTestCleanup()
  63. {
  64. PageBase<SilverlightAppLauncher>.DisposeWindow();
  65. SilverlightAppLauncher.UnloadBrowser(GetBrowserTitle());
  66. }
  67. #endregion
  68. #region Test Methods
  69. /// <summary>
  70. /// Tests if the Silverlight EA application is launched.
  71. /// </summary>
  72. [TestMethod]
  73. public void SilverlightEALaunchTest()
  74. {
  75. Assert.IsNotNull(EventAggregationPage<SilverlightAppLauncher>.Window, "EventAggregation application is not launched.");
  76. }
  77. /// <summary>
  78. /// Check if the add button click adds the selected fund to the selected customer.
  79. ///
  80. /// Repro Steps:
  81. /// 1. Launch the EventAggregation QS
  82. /// 2. Select a customer in the Customer combo box.
  83. /// 3. Select a fund in the Fund combo box.
  84. /// 4. Click on the add button
  85. /// 5. Check for the content displayed in the ArticleView displayed on the right side of the screen.
  86. ///
  87. /// Expected Result:
  88. /// On clicking the Add button, the selected fund should be added to the Activity view of the
  89. /// selected customer.
  90. /// </summary>
  91. [TestMethod]
  92. public void SilverlightAddFundToCustomer()
  93. {
  94. //Assert AddFund To Customer
  95. EventAggregationAssertion<SilverlightAppLauncher>.AssertAddFundToCustomer();
  96. }
  97. /// <summary>
  98. /// Check if the add button click adds the selected fund to the selected customer.
  99. ///
  100. /// Repro Steps:
  101. /// 1. Launch the EventAggregation QS
  102. /// 2. Select a customer in the Customer combo box.
  103. /// 3. Select a fund in the Fund combo box.
  104. /// 4. Click on the add button
  105. /// 5. Select another fund in Fund combo box
  106. /// 6. Click on the add button
  107. /// 7. Check for the content displayed in the ArticleView displayed on the right side of the screen.
  108. ///
  109. /// Expected Result:
  110. /// On clicking the Add button, the selected fund should be added to the Activity view of the
  111. /// selected customer.
  112. /// </summary>
  113. [TestMethod]
  114. public void SilverlightAddMultipleFundsToCustomer()
  115. {
  116. //Assert AddFund To Customer
  117. EventAggregationAssertion<SilverlightAppLauncher>.AssertAddMultipleFundsToCustomer();
  118. }
  119. #endregion
  120. #region private Methods
  121. private static string GetSilverlightApplication()
  122. {
  123. return ConfigHandler.GetValue("SilverlightAppLocation");
  124. }
  125. private static string GetSilverlightApplicationPath(int backTrackLength)
  126. {
  127. string currentDirectory = Directory.GetCurrentDirectory();
  128. if (!String.IsNullOrEmpty(currentDirectory) && Directory.Exists(currentDirectory))
  129. {
  130. for (int iIndex = 0; iIndex < backTrackLength; iIndex++)
  131. {
  132. currentDirectory = Directory.GetParent(currentDirectory).ToString();
  133. }
  134. }
  135. return currentDirectory + GetSilverlightApplication();
  136. }
  137. private static string GetBrowserTitle()
  138. {
  139. return new ResXConfigHandler(ConfigHandler.GetValue("ControlIdentifiersFile")).GetValue("SilverlightAppTitle");
  140. }
  141. #endregion
  142. }
  143. }