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

/V2.2/trunk/Quickstarts/Modularity/Modularity.Tests.AcceptanceTest/Modularity.Tests.AcceptanceTest/DefiningModulesInCode/Desktop/DefiningModulesInCodeDesktopFixture.cs

#
C# | 111 lines | 76 code | 13 blank | 22 comment | 0 complexity | f75030c480d58bd7b23584867f1c2f3c 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 Modularity.Tests.AcceptanceTest.TestEntities.Page;
 35using AcceptanceTestLibrary.ApplicationObserver;
 36using AcceptanceTestLibrary.Common.Desktop;
 37using Modularity.Tests.AcceptanceTest.TestEntities.Assertion;
 38using Modularity.Tests.AcceptanceTest.TestEntities.Action;
 39using System.Reflection;
 40
 41namespace Modularity.Tests.AcceptanceTest.DefiningModulesInCode.Desktop
 42{
 43    /// <summary>
 44    /// Acceptance test fixture for WPF application
 45    /// </summary>
 46#if DEBUG
 47    [DeploymentItem(@"..\DefiningModulesInCodeQuickstart\Desktop\Shell\bin\Debug\", "WPF")]
 48    [DeploymentItem(@".\Modularity.Tests.AcceptanceTest\bin\Debug\")]
 49#else
 50    [DeploymentItem(@"..\DefiningModulesInCodeQuickstart\Desktop\Shell\bin\Release\", "WPF")]
 51    [DeploymentItem(@".\Modularity.Tests.AcceptanceTest\bin\Release\")]
 52#endif
 53    [TestClass]
 54    public class DefiningModulesInCodeDesktopFixture : FixtureBase<WpfAppLauncher>
 55    {
 56        #region Additional test attributes
 57
 58        // Use TestInitialize to run code before running each test 
 59        [TestInitialize()]
 60        public void MyTestInitialize()
 61        {
 62            string currentOutputPath = (new System.IO.DirectoryInfo(Assembly.GetExecutingAssembly().Location)).Parent.FullName;
 63            Shell<WpfAppLauncher>.Window = base.LaunchApplication(currentOutputPath + GetDesktopApplication(), GetDesktopApplicationProcess())[0];
 64        }
 65
 66        // Use TestCleanup to run code after each test has run
 67        [TestCleanup()]
 68        public void MyTestCleanup()
 69        {
 70            Process p = WpfAppLauncher.GetCurrentAppProcess();
 71            base.UnloadApplication(p);
 72        }
 73
 74        #endregion
 75
 76        #region Test Methods
 77
 78        [TestMethod]
 79        public void DefineModulesInCodeDesktopApplicationLoadTest()
 80        {
 81            //check if window handle object is not null
 82            Assert.IsNotNull(Shell<WpfAppLauncher>.Window, "Defining Modules in Code is not launched.");
 83        }
 84
 85        [TestMethod]
 86        public void DefineModulesInCodeDesktopModuleLoadTest()
 87        {
 88            ShellAssertion<WpfAppLauncher>.AssertDefiningModulesInCode();
 89        }
 90
 91        [TestMethod]
 92        public void DefineModulesInCodeDesktopLoadModuleCOnDemand()
 93        {
 94            ShellAction<WpfAppLauncher>.LoadModuleCOnDemand();
 95            ShellAssertion<WpfAppLauncher>.AssertOnDemandDefineModulesInCodeCLoading();
 96        }
 97        #endregion
 98
 99        #region Private Methods
100        private static string GetDesktopApplicationProcess()
101        {
102            return ConfigHandler.GetValue("DefineModulesInCodeWpfAppProcessName");
103        }
104
105        private static string GetDesktopApplication()
106        {
107            return ConfigHandler.GetValue("DefineModulesInCodeWpfAppLocation");
108        }
109        #endregion
110    }
111}