PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms 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//===================================================================================
 33using System;
 34using System.Collections.Generic;
 35using System.Linq;
 36using System.Text;
 37using AcceptanceTestLibrary.Common;
 38using System.Windows.Automation;
 39using MultiTargeting.Tests.AcceptanceTest.TestEntities.Page;
 40using Microsoft.VisualStudio.TestTools.UnitTesting;
 41using AcceptanceTestLibrary.ApplicationHelper;
 42
 43namespace MultiTargeting.Tests.AcceptanceTest.TestEntities.Assertion
 44{
 45    public static class RealEstateListingViewerAssertion<TApp>
 46        where TApp : AppLauncherBase, new()
 47    {
 48
 49        #region LOADING OF CONTROLS
 50
 51        public static void AssertGarageImage()
 52        {
 53            InternalAssertControl(RealEstateListingViewerPage<TApp>.GarageImage, "Garage image is not loaded.");
 54        }
 55
 56        public static void AssertBathroomsImage()
 57        {
 58            InternalAssertControl(RealEstateListingViewerPage<TApp>.BathroomsImage, "Bathroom image is not loaded.");
 59        }
 60
 61        public static void AssertBedroomsImage()
 62        {
 63            InternalAssertControl(RealEstateListingViewerPage<TApp>.BedroomsImage, "Bedroom image is not loaded.");
 64        }
 65
 66        public static void AssertAcerageImage()
 67        {
 68            InternalAssertControl(RealEstateListingViewerPage<TApp>.AcerageImage, "Acerage image is not loaded.");
 69        }
 70
 71        public static void AssertPropertyImage()
 72        {
 73            InternalAssertControl(RealEstateListingViewerPage<TApp>.PropertyImage, "Property image is not loaded.");
 74        }
 75
 76        public static void AssertAddressTextBlockLoading()
 77        {
 78            InternalAssertControl(RealEstateListingViewerPage<TApp>.AddressAboveHouseImageText, "Address TextBlock (Above House Image) is not loaded.");
 79        }
 80
 81        public static void AssertCountyTextBlockLoading()
 82        {
 83            InternalAssertControl(RealEstateListingViewerPage<TApp>.CountyAboveHouseImageText, "County TextBlock (Above House Image) is not loaded.");
 84        }
 85
 86        public static void AssertStateTextBlockLoading()
 87        {
 88            InternalAssertControl(RealEstateListingViewerPage<TApp>.StateAboveHouseImageText, "State TextBlock (Above House Image) is not loaded.");
 89        }
 90
 91        public static void AssertZipCodeTextBlockLoading()
 92        {
 93            InternalAssertControl(RealEstateListingViewerPage<TApp>.ZipCodeText, "Zipcode TextBlock is not loaded.");
 94        }
 95
 96        public static void AssertBathroomsTextBlockLoading()
 97        {
 98            InternalAssertControl(RealEstateListingViewerPage<TApp>.BathroomsText, "Bathrooms TextBlock is not loaded.");
 99        }
100
101        public static void AssertGarageSizeTextBlockLoading()
102        {
103            InternalAssertControl(RealEstateListingViewerPage<TApp>.GarageSizeText, "Garage Size TextBlock is not loaded.");
104        }
105
106        public static void AssertBedroomsTextBlockLoading()
107        {
108            InternalAssertControl(RealEstateListingViewerPage<TApp>.BedroomsText, "Bedrooms TextBlock is not loaded.");
109        }
110
111        public static void AssertAcerageTextBlockLoading()
112        {
113            InternalAssertControl(RealEstateListingViewerPage<TApp>.AcerageText, "Acerage TextBlock is not loaded.");
114        }
115
116        public static void AssertPriceTextBlockLoading()
117        {
118            InternalAssertControl(RealEstateListingViewerPage<TApp>.PriceText, "Price TextBlock is not loaded.");
119        }
120
121        public static void AssertDescriptionLabelTextBlockLoading()
122        {
123            InternalAssertControl(RealEstateListingViewerPage<TApp>.DescriptionLabelText, "Description label is not loaded.");
124        }
125
126        public static void AssertDescriptionTextBlockLoading()
127        {
128            InternalAssertControl(RealEstateListingViewerPage<TApp>.DescriptionText, "Description TextBlock is not loaded.");
129        }
130
131        public static void AssertAddressBelowHouseImageTextBlockLoading()
132        {
133            InternalAssertControl(RealEstateListingViewerPage<TApp>.AddressBelowHouseImageText, "Address TextBlock below house image is not loaded.");
134        }
135
136        public static void AssertCountyBelowHouseImageTextBlockLoading()
137        {
138            InternalAssertControl(RealEstateListingViewerPage<TApp>.CountyBelowHouseImageText, "County TextBlock below house image is not loaded.");
139        }
140
141        public static void AssertStateBelowHouseImageTextBlockLoading()
142        {
143            InternalAssertControl(RealEstateListingViewerPage<TApp>.StateBelowHouseImageText, "State TextBlock below house image is not loaded.");
144        }
145
146
147        #endregion
148
149        #region CONTENT OF CONTROLS
150
151        public static void AssertAddressTextBlockContent()
152        {
153            InternalAssertContent(RealEstateListingViewerPage<TApp>.AddressAboveHouseImageText, "Address", "Actual and expected address are not same.");
154        }
155
156        public static void AssertCountyTextBlockContent()
157        {
158            InternalAssertContent(RealEstateListingViewerPage<TApp>.CountyAboveHouseImageText, "County", "Actual and expected county are not same.");
159        }
160
161        public static void AssertStateTextBlockContent()
162        {
163            InternalAssertContent(RealEstateListingViewerPage<TApp>.StateAboveHouseImageText, "State", "Actual and expected state are not same.");
164        }
165
166        public static void AssertZipCodeTextBlockContent()
167        {
168            InternalAssertContent(RealEstateListingViewerPage<TApp>.ZipCodeText, "ZipCode", "Actual and expected zipcode are not same.");
169        }
170
171        public static void AssertBathroomsTextBlockContent()
172        {
173            InternalAssertContent(RealEstateListingViewerPage<TApp>.BathroomsText, "Bathrooms", "Actual and expected bathroom values are not same.");
174        }
175
176        public static void AssertGarageSizeTextBlockContent()
177        {
178            InternalAssertContent(RealEstateListingViewerPage<TApp>.GarageSizeText, "GarageSize", "Actual and expected size of garage are not same.");
179        }
180
181        public static void AssertBedroomsTextBlockContent()
182        {
183            InternalAssertContent(RealEstateListingViewerPage<TApp>.BedroomsText, "Bedrooms", "Actual and expected bedroom values are not same.");
184        }
185
186        public static void AssertAcerageTextBlockContent()
187        {
188            InternalAssertContent(RealEstateListingViewerPage<TApp>.AcerageText, "Acerage", "Actual and expected acerage values are not same.");
189        }
190
191        public static void AssertPriceTextBlockContent()
192        {
193            InternalAssertContent(RealEstateListingViewerPage<TApp>.PriceText, "Price", "Actual and expected price are not same.");
194        }
195
196        public static void AssertDescriptionLabelTextBlockContentSilverlight()
197        {
198            InternalAssertContent(RealEstateListingViewerPage<TApp>.DescriptionLabelText, "DescriptionLabelSilverlight", "Actual and expected description label values are not same.");
199        }
200
201        public static void AssertDescriptionLabelTextBlockContentWPF()
202        {
203            InternalAssertContent(RealEstateListingViewerPage<TApp>.DescriptionLabelText, "DescriptionLabelWpf", "Actual and expected description label values are not same.");
204        }
205
206        public static void AssertDescriptionTextBlockContent()
207        {
208            InternalAssertContent(RealEstateListingViewerPage<TApp>.DescriptionText, "DescriptionText", "Actual and expected description text values are not same.");
209        }
210
211        public static void AssertAddressBelowHouseImageTextBlockContent()
212        {
213            InternalAssertContent(RealEstateListingViewerPage<TApp>.AddressBelowHouseImageText, "Address", "Actual and expected address are not same.");
214        }
215
216        public static void AssertCountyBelowHouseImageTextBlockContent()
217        {
218            InternalAssertContent(RealEstateListingViewerPage<TApp>.CountyBelowHouseImageText, "County", "Actual and expected county are not same.");
219        }
220
221        public static void AssertStateBelowHouseImageTextBlockContent()
222        {
223            InternalAssertContent(RealEstateListingViewerPage<TApp>.StateBelowHouseImageText, "State", "Actual and expected state are not same.");
224        }
225
226        
227        #endregion
228
229        private static void InternalAssertControl(AutomationElement control, string message)
230        {
231            Assert.IsNotNull(control, message);
232        }
233
234        private static void InternalAssertContent(AutomationElement aeControl, string nameValue, string message)
235        {
236            //find text block using AutomationElement of window
237            string actualValue;
238            string expectedValue;
239            ResXConfigHandler resx = new ResXConfigHandler(ConfigHandler.GetValue("TestDataInputFile"));
240
241            actualValue = aeControl.Current.Name;
242            expectedValue = resx.GetValue(nameValue);
243            Assert.AreEqual(expectedValue, actualValue, true, message);
244        }
245    }
246}