PageRenderTime 35ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/V4/Quickstarts/MultiTargeting/MultiTargeting.Tests.AcceptanceTest/MultiTargeting.Tests.AcceptanceTest/TestEntities/Assertion/RealEstateListingViewerAssertion.cs

#
C# | 246 lines | 169 code | 44 blank | 33 comment | 0 complexity | f1c12e5b8135d68b6777eef61c0ba750 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. //===================================================================================
  18. // Microsoft patterns & practices
  19. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  20. //===================================================================================
  21. // Copyright (c) Microsoft Corporation. All rights reserved.
  22. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  23. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  24. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  25. // FITNESS FOR A PARTICULAR PURPOSE.
  26. //===================================================================================
  27. // The example companies, organizations, products, domain names,
  28. // e-mail addresses, logos, people, places, and events depicted
  29. // herein are fictitious. No association with any real company,
  30. // organization, product, domain name, email address, logo, person,
  31. // places, or events is intended or should be inferred.
  32. //===================================================================================
  33. using System;
  34. using System.Collections.Generic;
  35. using System.Linq;
  36. using System.Text;
  37. using AcceptanceTestLibrary.Common;
  38. using System.Windows.Automation;
  39. using MultiTargeting.Tests.AcceptanceTest.TestEntities.Page;
  40. using Microsoft.VisualStudio.TestTools.UnitTesting;
  41. using AcceptanceTestLibrary.ApplicationHelper;
  42. namespace MultiTargeting.Tests.AcceptanceTest.TestEntities.Assertion
  43. {
  44. public static class RealEstateListingViewerAssertion<TApp>
  45. where TApp : AppLauncherBase, new()
  46. {
  47. #region LOADING OF CONTROLS
  48. public static void AssertGarageImage()
  49. {
  50. InternalAssertControl(RealEstateListingViewerPage<TApp>.GarageImage, "Garage image is not loaded.");
  51. }
  52. public static void AssertBathroomsImage()
  53. {
  54. InternalAssertControl(RealEstateListingViewerPage<TApp>.BathroomsImage, "Bathroom image is not loaded.");
  55. }
  56. public static void AssertBedroomsImage()
  57. {
  58. InternalAssertControl(RealEstateListingViewerPage<TApp>.BedroomsImage, "Bedroom image is not loaded.");
  59. }
  60. public static void AssertAcerageImage()
  61. {
  62. InternalAssertControl(RealEstateListingViewerPage<TApp>.AcerageImage, "Acerage image is not loaded.");
  63. }
  64. public static void AssertPropertyImage()
  65. {
  66. InternalAssertControl(RealEstateListingViewerPage<TApp>.PropertyImage, "Property image is not loaded.");
  67. }
  68. public static void AssertAddressTextBlockLoading()
  69. {
  70. InternalAssertControl(RealEstateListingViewerPage<TApp>.AddressAboveHouseImageText, "Address TextBlock (Above House Image) is not loaded.");
  71. }
  72. public static void AssertCountyTextBlockLoading()
  73. {
  74. InternalAssertControl(RealEstateListingViewerPage<TApp>.CountyAboveHouseImageText, "County TextBlock (Above House Image) is not loaded.");
  75. }
  76. public static void AssertStateTextBlockLoading()
  77. {
  78. InternalAssertControl(RealEstateListingViewerPage<TApp>.StateAboveHouseImageText, "State TextBlock (Above House Image) is not loaded.");
  79. }
  80. public static void AssertZipCodeTextBlockLoading()
  81. {
  82. InternalAssertControl(RealEstateListingViewerPage<TApp>.ZipCodeText, "Zipcode TextBlock is not loaded.");
  83. }
  84. public static void AssertBathroomsTextBlockLoading()
  85. {
  86. InternalAssertControl(RealEstateListingViewerPage<TApp>.BathroomsText, "Bathrooms TextBlock is not loaded.");
  87. }
  88. public static void AssertGarageSizeTextBlockLoading()
  89. {
  90. InternalAssertControl(RealEstateListingViewerPage<TApp>.GarageSizeText, "Garage Size TextBlock is not loaded.");
  91. }
  92. public static void AssertBedroomsTextBlockLoading()
  93. {
  94. InternalAssertControl(RealEstateListingViewerPage<TApp>.BedroomsText, "Bedrooms TextBlock is not loaded.");
  95. }
  96. public static void AssertAcerageTextBlockLoading()
  97. {
  98. InternalAssertControl(RealEstateListingViewerPage<TApp>.AcerageText, "Acerage TextBlock is not loaded.");
  99. }
  100. public static void AssertPriceTextBlockLoading()
  101. {
  102. InternalAssertControl(RealEstateListingViewerPage<TApp>.PriceText, "Price TextBlock is not loaded.");
  103. }
  104. public static void AssertDescriptionLabelTextBlockLoading()
  105. {
  106. InternalAssertControl(RealEstateListingViewerPage<TApp>.DescriptionLabelText, "Description label is not loaded.");
  107. }
  108. public static void AssertDescriptionTextBlockLoading()
  109. {
  110. InternalAssertControl(RealEstateListingViewerPage<TApp>.DescriptionText, "Description TextBlock is not loaded.");
  111. }
  112. public static void AssertAddressBelowHouseImageTextBlockLoading()
  113. {
  114. InternalAssertControl(RealEstateListingViewerPage<TApp>.AddressBelowHouseImageText, "Address TextBlock below house image is not loaded.");
  115. }
  116. public static void AssertCountyBelowHouseImageTextBlockLoading()
  117. {
  118. InternalAssertControl(RealEstateListingViewerPage<TApp>.CountyBelowHouseImageText, "County TextBlock below house image is not loaded.");
  119. }
  120. public static void AssertStateBelowHouseImageTextBlockLoading()
  121. {
  122. InternalAssertControl(RealEstateListingViewerPage<TApp>.StateBelowHouseImageText, "State TextBlock below house image is not loaded.");
  123. }
  124. #endregion
  125. #region CONTENT OF CONTROLS
  126. public static void AssertAddressTextBlockContent()
  127. {
  128. InternalAssertContent(RealEstateListingViewerPage<TApp>.AddressAboveHouseImageText, "Address", "Actual and expected address are not same.");
  129. }
  130. public static void AssertCountyTextBlockContent()
  131. {
  132. InternalAssertContent(RealEstateListingViewerPage<TApp>.CountyAboveHouseImageText, "County", "Actual and expected county are not same.");
  133. }
  134. public static void AssertStateTextBlockContent()
  135. {
  136. InternalAssertContent(RealEstateListingViewerPage<TApp>.StateAboveHouseImageText, "State", "Actual and expected state are not same.");
  137. }
  138. public static void AssertZipCodeTextBlockContent()
  139. {
  140. InternalAssertContent(RealEstateListingViewerPage<TApp>.ZipCodeText, "ZipCode", "Actual and expected zipcode are not same.");
  141. }
  142. public static void AssertBathroomsTextBlockContent()
  143. {
  144. InternalAssertContent(RealEstateListingViewerPage<TApp>.BathroomsText, "Bathrooms", "Actual and expected bathroom values are not same.");
  145. }
  146. public static void AssertGarageSizeTextBlockContent()
  147. {
  148. InternalAssertContent(RealEstateListingViewerPage<TApp>.GarageSizeText, "GarageSize", "Actual and expected size of garage are not same.");
  149. }
  150. public static void AssertBedroomsTextBlockContent()
  151. {
  152. InternalAssertContent(RealEstateListingViewerPage<TApp>.BedroomsText, "Bedrooms", "Actual and expected bedroom values are not same.");
  153. }
  154. public static void AssertAcerageTextBlockContent()
  155. {
  156. InternalAssertContent(RealEstateListingViewerPage<TApp>.AcerageText, "Acerage", "Actual and expected acerage values are not same.");
  157. }
  158. public static void AssertPriceTextBlockContent()
  159. {
  160. InternalAssertContent(RealEstateListingViewerPage<TApp>.PriceText, "Price", "Actual and expected price are not same.");
  161. }
  162. public static void AssertDescriptionLabelTextBlockContentSilverlight()
  163. {
  164. InternalAssertContent(RealEstateListingViewerPage<TApp>.DescriptionLabelText, "DescriptionLabelSilverlight", "Actual and expected description label values are not same.");
  165. }
  166. public static void AssertDescriptionLabelTextBlockContentWPF()
  167. {
  168. InternalAssertContent(RealEstateListingViewerPage<TApp>.DescriptionLabelText, "DescriptionLabelWpf", "Actual and expected description label values are not same.");
  169. }
  170. public static void AssertDescriptionTextBlockContent()
  171. {
  172. InternalAssertContent(RealEstateListingViewerPage<TApp>.DescriptionText, "DescriptionText", "Actual and expected description text values are not same.");
  173. }
  174. public static void AssertAddressBelowHouseImageTextBlockContent()
  175. {
  176. InternalAssertContent(RealEstateListingViewerPage<TApp>.AddressBelowHouseImageText, "Address", "Actual and expected address are not same.");
  177. }
  178. public static void AssertCountyBelowHouseImageTextBlockContent()
  179. {
  180. InternalAssertContent(RealEstateListingViewerPage<TApp>.CountyBelowHouseImageText, "County", "Actual and expected county are not same.");
  181. }
  182. public static void AssertStateBelowHouseImageTextBlockContent()
  183. {
  184. InternalAssertContent(RealEstateListingViewerPage<TApp>.StateBelowHouseImageText, "State", "Actual and expected state are not same.");
  185. }
  186. #endregion
  187. private static void InternalAssertControl(AutomationElement control, string message)
  188. {
  189. Assert.IsNotNull(control, message);
  190. }
  191. private static void InternalAssertContent(AutomationElement aeControl, string nameValue, string message)
  192. {
  193. //find text block using AutomationElement of window
  194. string actualValue;
  195. string expectedValue;
  196. ResXConfigHandler resx = new ResXConfigHandler(ConfigHandler.GetValue("TestDataInputFile"));
  197. actualValue = aeControl.Current.Name;
  198. expectedValue = resx.GetValue(nameValue);
  199. Assert.AreEqual(expectedValue, actualValue, true, message);
  200. }
  201. }
  202. }