/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. //===================================================================================
  17. using System;
  18. using System.Text;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using Microsoft.VisualStudio.TestTools.UnitTesting;
  22. using System.IO;
  23. using System.Diagnostics;
  24. using System.Threading;
  25. using System.Windows.Automation;
  26. using System.Windows.Automation.Peers;
  27. using System.Windows.Automation.Text;
  28. using System.Windows.Automation.Provider;
  29. using AcceptanceTestLibrary.ApplicationHelper;
  30. using AcceptanceTestLibrary.Common;
  31. using Modularity.Tests.AcceptanceTest.TestEntities.Page;
  32. using AcceptanceTestLibrary.ApplicationObserver;
  33. using AcceptanceTestLibrary.Common.Desktop;
  34. using Modularity.Tests.AcceptanceTest.TestEntities.Assertion;
  35. using Modularity.Tests.AcceptanceTest.TestEntities.Action;
  36. using System.Reflection;
  37. namespace Modularity.Tests.AcceptanceTest.DefiningModulesInCode.Desktop
  38. {
  39. /// <summary>
  40. /// Acceptance test fixture for WPF application
  41. /// </summary>
  42. #if DEBUG
  43. [DeploymentItem(@"..\DefiningModulesInCodeQuickstart\Desktop\Shell\bin\Debug\", "WPF")]
  44. [DeploymentItem(@".\Modularity.Tests.AcceptanceTest\bin\Debug\")]
  45. #else
  46. [DeploymentItem(@"..\DefiningModulesInCodeQuickstart\Desktop\Shell\bin\Release\", "WPF")]
  47. [DeploymentItem(@".\Modularity.Tests.AcceptanceTest\bin\Release\")]
  48. #endif
  49. [TestClass]
  50. public class DefiningModulesInCodeDesktopFixture : FixtureBase<WpfAppLauncher>
  51. {
  52. #region Additional test attributes
  53. // Use TestInitialize to run code before running each test
  54. [TestInitialize()]
  55. public void MyTestInitialize()
  56. {
  57. string currentOutputPath = (new System.IO.DirectoryInfo(Assembly.GetExecutingAssembly().Location)).Parent.FullName;
  58. Shell<WpfAppLauncher>.Window = base.LaunchApplication(currentOutputPath + GetDesktopApplication(), GetDesktopApplicationProcess())[0];
  59. }
  60. // Use TestCleanup to run code after each test has run
  61. [TestCleanup()]
  62. public void MyTestCleanup()
  63. {
  64. Process p = WpfAppLauncher.GetCurrentAppProcess();
  65. base.UnloadApplication(p);
  66. }
  67. #endregion
  68. #region Test Methods
  69. [TestMethod]
  70. public void DefineModulesInCodeDesktopApplicationLoadTest()
  71. {
  72. //check if window handle object is not null
  73. Assert.IsNotNull(Shell<WpfAppLauncher>.Window, "Defining Modules in Code is not launched.");
  74. }
  75. [TestMethod]
  76. public void DefineModulesInCodeDesktopModuleLoadTest()
  77. {
  78. ShellAssertion<WpfAppLauncher>.AssertDefiningModulesInCode();
  79. }
  80. [TestMethod]
  81. public void DefineModulesInCodeDesktopLoadModuleCOnDemand()
  82. {
  83. ShellAction<WpfAppLauncher>.LoadModuleCOnDemand();
  84. ShellAssertion<WpfAppLauncher>.AssertOnDemandDefineModulesInCodeCLoading();
  85. }
  86. #endregion
  87. #region Private Methods
  88. private static string GetDesktopApplicationProcess()
  89. {
  90. return ConfigHandler.GetValue("DefineModulesInCodeWpfAppProcessName");
  91. }
  92. private static string GetDesktopApplication()
  93. {
  94. return ConfigHandler.GetValue("DefineModulesInCodeWpfAppLocation");
  95. }
  96. #endregion
  97. }
  98. }