PageRenderTime 26ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms 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//===================================================================================
 17using System;
 18using System.Text;
 19using System.Collections.Generic;
 20using System.Linq;
 21using Microsoft.VisualStudio.TestTools.UnitTesting;
 22
 23using System.Windows.Automation;
 24using System.Windows.Automation.Peers;
 25using System.Windows.Automation.Text;
 26using System.Windows.Automation.Provider;
 27using AcceptanceTestLibrary.Common;
 28using AcceptanceTestLibrary.ApplicationHelper;
 29using System.IO;
 30using AcceptanceTestLibrary.Common.Silverlight;
 31using EventAggregation.Tests.AcceptanceTest.TestEntities.Page;
 32using EventAggregation.Tests.AcceptanceTest.TestEntities.Assertion;
 33using AcceptanceTestLibrary.TestEntityBase;
 34using System.Reflection;
 35using System.Threading;
 36
 37namespace EventAggregation.Tests.AcceptanceTest.Silverlight
 38{
 39    /// <summary>
 40    /// Summary description for EventAggregation
 41    /// </summary>
 42#if DEBUG
 43    [DeploymentItem(@"..\Silverlight\bin\Debug", "SL")]
 44    [DeploymentItem(@".\EventAggregation.Tests.AcceptanceTest\bin\Debug")]
 45#else
 46    [DeploymentItem(@"..\Silverlight\bin\Release", "SL")]
 47    [DeploymentItem(@".\EventAggregation.Tests.AcceptanceTest\bin\Release")]
 48#endif
 49
 50    [TestClass]
 51    public class EventAggregation_Silverlight_Tests : FixtureBase<SilverlightAppLauncher>
 52    {
 53        private const int BACKTRACKLENGTH = 4;
 54
 55        #region Additional test attributes
 56        // Use TestInitialize to run code before running each test 
 57        [TestInitialize()]
 58        public void MyTestInitialize()
 59        {
 60            string currentOutputPath = (new System.IO.DirectoryInfo(Assembly.GetExecutingAssembly().Location)).Parent.FullName;
 61            EventAggregationPage<SilverlightAppLauncher>.Window = base.LaunchApplication(currentOutputPath + GetSilverlightApplication(), GetBrowserTitle())[0];
 62            Thread.Sleep(5000);   
 63        }
 64        
 65        // Use TestCleanup to run code after each test has run
 66        [TestCleanup()]
 67        public void MyTestCleanup()
 68        {
 69            PageBase<SilverlightAppLauncher>.DisposeWindow();
 70            SilverlightAppLauncher.UnloadBrowser(GetBrowserTitle());
 71        }
 72
 73        #endregion
 74
 75        #region Test Methods
 76        /// <summary>
 77        /// Tests if the Silverlight EA application is launched.
 78        /// </summary>
 79        [TestMethod]
 80        public void SilverlightEALaunchTest()
 81        {
 82            Assert.IsNotNull(EventAggregationPage<SilverlightAppLauncher>.Window, "EventAggregation application is not launched.");
 83        }
 84
 85        /// <summary>
 86        /// Check if the add button click adds the selected fund to the selected customer.
 87        /// 
 88        /// Repro Steps:
 89        /// 1. Launch the EventAggregation QS
 90        /// 2. Select a customer in the Customer combo box.
 91        /// 3. Select a fund in the Fund combo box.
 92        /// 4. Click on the add button
 93        /// 5. Check for the content displayed in the ArticleView displayed on the right side of the screen.
 94        /// 
 95        /// Expected Result:
 96        /// On clicking the Add button, the selected fund should be added to the Activity view of the
 97        /// selected customer.        
 98        /// </summary>
 99        [TestMethod]
100        public void SilverlightAddFundToCustomer()
101        {
102            //Assert AddFund To Customer
103            EventAggregationAssertion<SilverlightAppLauncher>.AssertAddFundToCustomer();
104        }
105
106        /// <summary>
107        /// Check if the add button click adds the selected fund to the selected customer.
108        /// 
109        /// Repro Steps:
110        /// 1. Launch the EventAggregation QS
111        /// 2. Select a customer in the Customer combo box.
112        /// 3. Select a fund in the Fund combo box.
113        /// 4. Click on the add button
114        /// 5. Select another fund in Fund combo box
115        /// 6. Click on the add button
116        /// 7. Check for the content displayed in the ArticleView displayed on the right side of the screen.
117        /// 
118        /// Expected Result:
119        /// On clicking the Add button, the selected fund should be added to the Activity view of the
120        /// selected customer.        
121        /// </summary>
122        [TestMethod]
123        public void SilverlightAddMultipleFundsToCustomer()
124        {
125            //Assert AddFund To Customer
126            EventAggregationAssertion<SilverlightAppLauncher>.AssertAddMultipleFundsToCustomer();
127        }
128        #endregion
129
130        #region private Methods
131
132        private static string GetSilverlightApplication()
133        {
134            return ConfigHandler.GetValue("SilverlightAppLocation");
135        }
136
137        private static string GetSilverlightApplicationPath(int backTrackLength)
138        {
139            string currentDirectory = Directory.GetCurrentDirectory();
140            if (!String.IsNullOrEmpty(currentDirectory) && Directory.Exists(currentDirectory))
141            {
142                for (int iIndex = 0; iIndex < backTrackLength; iIndex++)
143                {
144                    currentDirectory = Directory.GetParent(currentDirectory).ToString();
145                }
146            }
147            return currentDirectory + GetSilverlightApplication();
148        }
149
150        private static string GetBrowserTitle()
151        {
152            return new ResXConfigHandler(ConfigHandler.GetValue("ControlIdentifiersFile")).GetValue("SilverlightAppTitle");
153        }
154        #endregion
155    }
156}