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