PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/V2.2/trunk/RI/StockTraderRI.Tests.AcceptanceTest/StockTraderRI.Tests.AcceptanceTest/Desktop/StockTraderRIDesktopFixture.cs

#
C# | 382 lines | 263 code | 58 blank | 61 comment | 0 complexity | f60329e78b6c0139b75a5fe3d70dc846 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//===================================================================================
 17using System;
 18using System.Text;
 19using System.Collections.Generic;
 20using System.Linq;
 21using Microsoft.VisualStudio.TestTools.UnitTesting;
 22
 23using System.IO;
 24using System.Diagnostics;
 25using System.Threading;
 26
 27using System.Windows.Automation;
 28using System.Windows.Automation.Peers;
 29using System.Windows.Automation.Text;
 30using System.Windows.Automation.Provider;
 31
 32using AcceptanceTestLibrary.ApplicationHelper;
 33using AcceptanceTestLibrary.Common;
 34using StockTraderRI.Tests.AcceptanceTest.TestEntities.Page;
 35using StockTraderRI.Tests.AcceptanceTest.TestEntities.Assertion;
 36using StockTraderRI.Tests.AcceptanceTest.TestEntities.Action;
 37using AcceptanceTestLibrary.ApplicationObserver;
 38using AcceptanceTestLibrary.Common.Desktop;
 39using System.Reflection;
 40using AcceptanceTestLibrary.TestEntityBase;
 41
 42namespace StockTraderRI.Tests.AcceptanceTest.Desktop
 43{
 44    /// <summary>
 45    /// Acceptance test fixture for WPF application
 46    /// </summary>
 47#if DEBUG
 48    [DeploymentItem(@"..\Desktop\StockTraderRI\bin\Debug", "WPF")]
 49    [DeploymentItem(@".\StockTraderRI.Tests.AcceptanceTest\bin\Debug")]
 50#else
 51    [DeploymentItem(@"..\Desktop\StockTraderRI\bin\Release", "WPF")]
 52    [DeploymentItem(@".\StockTraderRI.Tests.AcceptanceTest\bin\Release")]
 53#endif
 54    [TestClass]
 55    public class StockTraderRIDesktopFixture : FixtureBase<WpfAppLauncher>
 56    {
 57        #region Additional test attributes
 58
 59        // Use TestInitialize to run code before running each test 
 60        [TestInitialize()]
 61        public void MyTestInitialize()
 62        {
 63            string currentOutputPath = (new System.IO.DirectoryInfo(Assembly.GetExecutingAssembly().Location)).Parent.FullName;
 64            StockTraderRIPage<WpfAppLauncher>.Window = base.LaunchApplication(currentOutputPath + GetDesktopApplication(), GetDesktopApplicationProcess())[0];
 65        }
 66
 67        // Use TestCleanup to run code after each test has run
 68        [TestCleanup()]
 69        public void MyTestCleanup()
 70        {
 71            PageBase<WpfAppLauncher>.DisposeWindow();
 72            Process p = WpfAppLauncher.GetCurrentAppProcess();
 73            base.UnloadApplication(p);
 74        }
 75
 76        #endregion
 77
 78        #region Test Methods
 79
 80        #region Application Launch Test
 81        [TestMethod]
 82        public void DesktopApplicationLoadTest()
 83        {
 84            Assert.IsNotNull(StockTraderRIPage<WpfAppLauncher>.Window, "StockTraderRI is not launched.");
 85        }
 86        #endregion
 87
 88        #endregion
 89
 90        #region Position summary Module Load Test
 91
 92        /// <summary>
 93        /// Tests if position summary details are loaded.
 94        /// </summary>
 95        [TestMethod]
 96        public void DesktopApplicationPositionSummaryTest()
 97        {
 98            InvokePositionSummaryAssert();
 99        }
100
101        /// <summary>
102        /// Tests the number of columns from position summary view table. 
103        /// </summary>
104        /// 
105
106        [TestMethod]
107        public void DesktopApplicationPositionSummaryColumnCountTest()
108        {
109
110            //For now the test data is hardcoded in resource file. But if the datasource is available it will be read from the datasource
111            StockTraderRIAssertion<WpfAppLauncher>.DesktopAssertPositionSummaryColumnCount();
112        }
113
114        /// <summary>
115        /// Tests the number of rows from position summary view table. 
116        /// </summary>
117
118        [TestMethod]
119        public void DesktopApplicationPositionSummaryRowCountTest()
120        {
121            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionSummaryRowCount();
122        }
123
124        /// <summary>
125        /// Tests the computed value (Market value & Gain Loss %) with the value loaded in the screen
126        /// </summary>
127        /// 
128
129        [TestMethod]
130        public void DesktopApplicationPositionSummaryDataTest()
131        {
132            //For each Stock or Symbol take the old value and get the value from Web service and monitor that
133
134            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionSummaryValuesForSymbol();
135        }
136
137        #endregion
138
139        #region Market Trend Test
140        /// <summary>
141        /// Tests the Historical Data Block is loaded 
142        /// </summary>
143        /// 
144
145        [TestMethod]
146        public void DesktopApplicationMarketTrendTest()
147        {
148            StockTraderRIAssertion<WpfAppLauncher>.AssertHistoricalDataText();
149        }
150
151        /// <summary>
152        /// Tests the Pie Chart Data Block is loaded 
153        /// </summary>
154        /// 
155
156        [TestMethod]
157        public void DesktopApplicationPieChartTextLoadTest()
158        {
159            StockTraderRIAssertion<WpfAppLauncher>.AssertPieChartTextBlock();
160        }
161        #endregion
162
163        #region PositionBuySellTab Test
164        [TestMethod]
165        public void DesktopPositionBuySellTabControlsLoadTest()
166        {
167            InvokeDesktopPositionBuySellTabControlsLoad("Buy");
168        }
169
170
171        [TestMethod]
172        public void DesktopAttemptBuyStockWithValidData()
173        {
174            InvokeAttemptBuySellOrderWithValidData("Buy");
175        }
176
177        [TestMethod]
178        public void DesktopAttemptBuyStockWithInValidData()
179        {
180            InvokeAttemptBuySellOrderWithInValidData("Buy");
181        }
182        [TestMethod]
183        public void DesktopAttemptSellStockWithValidData()
184        {
185            InvokeAttemptBuySellOrderWithValidData("Sell");
186        }
187        [TestMethod]
188        public void DesktopAttemptSellStockWithInValidData()
189        {
190            InvokeAttemptBuySellOrderWithInValidData("Sell");
191        }
192        [TestMethod]
193        public void DesktopAttemptStockBuySellCancelByCancelButton()
194        {
195            InvokeAttemptOrderCancelByCancelButton();
196        }
197        [TestMethod]
198        public void DesktopProcessMultipleStockBuySellBySubmitAllButtonforValidData()
199        {
200            InvokeProcessMultipleStockBuySellBySubmitAllButtonforValidData();
201        }
202        [TestMethod]
203        public void DesktopProcessMultipleStockBuySellBySubmitAllButtonforInValidData()
204        {
205            InvokeProcessMultipleStockBuySellBySubmitAllButtonforInValidData();
206        }
207        [TestMethod]
208        public void DesktopProcessMultipleStockBuySellByCancelAllButton()
209        {
210            InvokeProcessMultipleStockBuySellByCancelAllButton();
211        }
212
213        #endregion
214
215        #region WatchList Module Test
216
217        /// <summary>
218        /// Tests the Watch List Grid is loaded 
219        /// </summary>
220        /// 
221               [TestMethod]
222        public void DesktopApplicationWatchListGridLoadTest()
223        {
224            StockTraderRIAssertion<WpfAppLauncher>.AssertWatchListGrid();
225        }
226
227     
228        #endregion
229
230        #region NewsArticle Module Load Test
231        /// <summary>
232        /// Tests the News Articles Data Block is loaded 
233        /// </summary>
234        /// 
235
236        [TestMethod]
237        public void DesktopApplicationNewsArticleTextLoadTest()
238        {
239            StockTraderRIAssertion<WpfAppLauncher>.AssertNewsArticleText();
240        }
241        #endregion
242
243        #region Watch List Module Test
244        
245        /// <summary>
246        /// Tests the AddtoWatchList Button and the text Box is loaded
247        /// </summary>
248        /// 
249
250        [TestMethod]
251        public void DesktopApplicationAddtoWatchListTextBoxLoadTest()
252        {
253            InvokeAddtoWatchListAssert();
254        }
255
256
257        [TestMethod]
258        public void DesktopStockRemovedfromWatchListTextBoxTest()
259        {
260            InvokeStockRemovedfromWatchListTextBoxAssert();
261        }
262
263        /// <summary>
264        /// Tests the stock added in the TextBox gets added to the Watch List Grid on Clicking the AddtoWatchList Button
265        /// </summary>
266        /// 
267        [TestMethod]
268        public void DesktopApplicationStockAddedinWatchListTextBoxTest()
269        {
270            InvokeStockAddedinWatchListTextBoxAssert();
271        }
272        #endregion
273
274        #region private methods
275        private static string GetDesktopApplicationProcess()
276        {
277            return ConfigHandler.GetValue("WpfAppProcessName");
278        }
279
280        private static string GetDesktopApplication()
281        {
282            return ConfigHandler.GetValue("WpfAppLocation");
283        }
284
285        private void InvokePositionSummaryAssert()
286        {
287            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionSummaryTab();
288            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionSummaryGrid();
289        }
290        private void InvokeOrderToolBarAssert()
291        {
292            StockTraderRIAssertion<WpfAppLauncher>.AssertSubmitButton();
293            StockTraderRIAssertion<WpfAppLauncher>.AssertSubmitAllButton();
294            StockTraderRIAssertion<WpfAppLauncher>.AssertCancelButton();
295            StockTraderRIAssertion<WpfAppLauncher>.AssertCancelAllButton();
296        }
297        private void InvokeAddtoWatchListAssert()
298        {
299            StockTraderRIAssertion<WpfAppLauncher>.AssertTextBoxBlock();
300        }
301        private void InvokeStockAddedinWatchListTextBoxAssert()
302        {
303            StockTraderRIAssertion<WpfAppLauncher>.AssertStockAddedinWatchListTextBox();
304            StockTraderRIAssertion<WpfAppLauncher>.AssertWatchListRowCount();
305        }
306
307        private void InvokeStockRemovedfromWatchListTextBoxAssert()
308        {
309            StockTraderRIAssertion<WpfAppLauncher>.AssertStockAddedinWatchListTextBox();
310            StockTraderRIAssertion<WpfAppLauncher>.AssertWatchListRowCount();
311            StockTraderRIAssertion<WpfAppLauncher>.AssertStockRemovedfromWatchListTextBox();
312        }
313
314        private void InvokeDesktopPositionBuySellTabControlsLoad(string option)
315        {
316            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionSummaryTab();
317            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionBuyButtonClickTest(option);
318
319            StockTraderRIAssertion<WpfAppLauncher>.AssertTermComboBox();
320            StockTraderRIAssertion<WpfAppLauncher>.AssertPriceLimitTextBox();
321            StockTraderRIAssertion<WpfAppLauncher>.AssertSellRadioButton();
322            StockTraderRIAssertion<WpfAppLauncher>.AssertBuyRadioButton();
323            StockTraderRIAssertion<WpfAppLauncher>.AssertSharesTextBox();
324
325            StockTraderRIAssertion<WpfAppLauncher>.AssertOrderTypeComboBox();
326            StockTraderRIAssertion<WpfAppLauncher>.AssertOrderCommandSubmit();
327            StockTraderRIAssertion<WpfAppLauncher>.AssertOrderCommandCancel();
328            StockTraderRIAssertion<WpfAppLauncher>.AssertOrderCommandSubmitAllButton();
329            StockTraderRIAssertion<WpfAppLauncher>.AssertOrderCommandCancelAllButton();
330        }
331        private void InvokeAttemptBuySellOrderWithValidData(string option)
332        {
333            InvokeDesktopPositionBuySellTabControlsLoad(option);
334            StockTraderRIAssertion<WpfAppLauncher>.AssertAttemptBuySellOrderWithValidData();
335        }
336
337        private void InvokeAttemptBuySellOrderWithInValidData(string option)
338        {
339            InvokeDesktopPositionBuySellTabControlsLoad(option);
340            StockTraderRIAssertion<WpfAppLauncher>.AssertAttemptBuySellOrderWithInValidData();
341        }
342
343        private void InvokeAttemptOrderCancelByCancelButton()
344        {
345            InvokeDesktopPositionBuySellTabControlsLoad("Buy");
346            StockTraderRIAssertion<WpfAppLauncher>.AssertAttemptOrderCancelByCancelButton();
347        }
348
349        private void InvokeProcessMultipleStockBuySellBySubmitAllButtonforValidData()
350        {
351            InvokeDesktopPositionBuySellTabLoad();
352            
353            StockTraderRIAssertion<WpfAppLauncher>.AssertProcessMultipleStockBuySellBySubmitAllButtonforValidData();
354        }
355
356        private void InvokeDesktopPositionBuySellTabLoad()
357        {
358            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionSummaryTab();
359            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionBuyButtonClickTest("Buy");
360        }
361
362
363        private void InvokeProcessMultipleStockBuySellBySubmitAllButtonforInValidData()
364        {
365            InvokeSilverLightPositionBuySellTabLoad();
366            StockTraderRIAssertion<WpfAppLauncher>.AssertProcessMultipleStockBuySellBySubmitAllButtonforInValidData();
367        }
368        private void InvokeSilverLightPositionBuySellTabLoad()
369        {
370            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionSummaryTab();
371            StockTraderRIAssertion<WpfAppLauncher>.AssertPositionBuyButtonClickTest("Buy");
372        }
373
374
375        private void InvokeProcessMultipleStockBuySellByCancelAllButton()
376        {
377            InvokeDesktopPositionBuySellTabLoad();
378            StockTraderRIAssertion<WpfAppLauncher>.AssertProcessMultipleStockBuySellByCancelAllButton();
379        }
380        #endregion
381    }
382}