PageRenderTime 34ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/PrismLibrary/Desktop/Prism.UnityExtensions.Tests/UnityBootstrapperNullModuleManagerFixture.cs

#
C# | 82 lines | 52 code | 13 blank | 17 comment | 0 complexity | cc0f1b74e89404f225b96613c4f886dd 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.Collections.Generic;
  19. using System.Linq;
  20. using System.Text;
  21. using Microsoft.VisualStudio.TestTools.UnitTesting;
  22. using Microsoft.Practices.Prism.Regions;
  23. using System.Windows;
  24. using Microsoft.Practices.ServiceLocation;
  25. using Microsoft.Practices.Unity;
  26. using Microsoft.Practices.Prism.UnityExtensions;
  27. using Microsoft.Practices.Prism.Logging;
  28. namespace Microsoft.Practices.Prism.UnityExtensions.Tests
  29. {
  30. [TestClass]
  31. public class UnityBootstrapperNullModuleManagerFixture
  32. {
  33. [TestMethod]
  34. public void RunShouldNotCallInitializeModulesWhenModuleManagerNotFound()
  35. {
  36. var bootstrapper = new NullModuleManagerBootstrapper();
  37. bootstrapper.Run();
  38. Assert.IsFalse(bootstrapper.InitializeModulesCalled);
  39. }
  40. private class NullModuleManagerBootstrapper : UnityBootstrapper
  41. {
  42. public bool InitializeModulesCalled;
  43. protected override void ConfigureContainer()
  44. {
  45. //base.RegisterDefaultTypesIfMissing();
  46. this.Container.AddNewExtension<UnityBootstrapperExtension>();
  47. Container.RegisterInstance<ILoggerFacade>(Logger);
  48. this.Container.RegisterInstance(this.ModuleCatalog);
  49. RegisterTypeIfMissing(typeof(IServiceLocator), typeof(UnityServiceLocatorAdapter), true);
  50. }
  51. protected override IRegionBehaviorFactory ConfigureDefaultRegionBehaviors()
  52. {
  53. return null;
  54. }
  55. protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
  56. {
  57. return null;
  58. }
  59. protected override DependencyObject CreateShell()
  60. {
  61. return null;
  62. }
  63. protected override void InitializeModules()
  64. {
  65. this.InitializeModulesCalled = true;
  66. }
  67. }
  68. }
  69. }