Example #1
0
        public void ConfigureModulesUsesModuleEnumeratorAndModuleLoaderService()
        {
            TestableWebClientApplication     app       = new TestableWebClientApplication();
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            app.SetTestRootCompositionContainer(container);
            MockModuleEnumerator moduleEnumerator = new MockModuleEnumerator();

            ModuleInfo moduleInfo = new ModuleInfo("TestModuleName", string.Empty, string.Empty);

            moduleEnumerator.ModulesData.Add(moduleInfo);
            container.Services.Add(typeof(IModuleEnumerator), moduleEnumerator);

            MockModuleLoaderService moduleLoader = new MockModuleLoaderService();

            container.Services.Add(typeof(IModuleLoaderService), moduleLoader);

            MockModuleConfigurationLocatorService configurationLocator = new MockModuleConfigurationLocatorService();

            container.Services.Add(typeof(IModuleConfigurationLocatorService), configurationLocator);

            app.TestConfigureModules();

            Assert.AreEqual("TestModuleName", configurationLocator.ModuleName);
            Assert.AreEqual("TestModuleName", moduleLoader.ModuleName);
        }
Example #2
0
        public void AspxPagesAreNotAddedToLifetimeContainer()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();
            MockHttpContext mockContext = new MockHttpContext();
            MockPage        mockPage    = new MockPage();

            mockContext.Request             = new HttpRequest("page.aspx", "http://application/page.aspx", null);
            mockContext.Handler             = mockPage;
            mockContext.ApplicationInstance = application;
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            application.ModuleContainer = container;
            application.SetTestCurrentContext(mockContext);

            application.TestRun();

            int lifetimeObjects = container.Locator.Count;

            //application.TestPreRequestHandlerExecute(mockContext);
            mockPage.CallOnInit();

            Assert.IsNotNull(mockPage.Presenter);
            Assert.IsNull(container.Locator.Get <MockPresenter>());
            Assert.IsNull(container.Locator.Get <MockPage>());

            //application.TestPostRequestHandlerExecute(mockContext);

            Assert.AreEqual(lifetimeObjects, container.Locator.Count);
        }
Example #3
0
        public void TestRootContainerCreatedByCreateRootContainer()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();

            application.TestRun();

            Assert.IsTrue(application.RooContainerCreated);
            Assert.IsNotNull(application.RootContainer);
        }
Example #4
0
        public void TestPageBuilderIsCreatedByCreatePageBuilder()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();

            application.TestRun();

            Assert.IsTrue(application.PageBuilderCreated);
            Assert.IsNotNull(application.PageBuilder);
        }
Example #5
0
        public void AddRequiredServicesAddsModuleContainerLocatorService()
        {
            TestableWebClientApplication     app       = new TestableWebClientApplication();
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            app.SetTestRootCompositionContainer(container);

            app.TestAddRequiredServices();

            container.Services.Contains <ModuleContainerLocatorService>();
        }
Example #6
0
        public void AddRequiredServicesAddsWebConfigModuleInfoStore()
        {
            TestableWebClientApplication     app       = new TestableWebClientApplication();
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            app.SetTestRootCompositionContainer(container);

            app.TestAddRequiredServices();

            container.Services.Contains <WebConfigModuleInfoStore>();
        }
Example #7
0
        public void AddRequiredServicesAddsAuthorizationRulesService()
        {
            TestableWebClientApplication     app       = new TestableWebClientApplication();
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            app.SetTestRootCompositionContainer(container);

            app.TestAddRequiredServices();

            container.Services.Contains <AuthorizationRulesService>();
        }
Example #8
0
        public void AddRequiredServicesAddsVirtualPathUtilityService()
        {
            TestableWebClientApplication     app       = new TestableWebClientApplication();
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            app.SetTestRootCompositionContainer(container);

            app.TestAddRequiredServices();

            container.Services.Contains <VirtualPathUtilityService>();
        }
Example #9
0
        public void CreateRootContainerInitializesContainer()
        {
            TestableWebClientApplication app = new TestableWebClientApplication();

            app.InitializeApplicationBuilder();

            app.TestCreateRootContainer();

            Assert.IsNotNull(app.RootContainer);
            Assert.IsNotNull(app.RootContainer.Builder);
            Assert.IsNotNull(app.RootContainer.Locator);
        }
Example #10
0
        public void ExtensionPointsAreBeingCalled()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();
            MockHttpContext mockContext = new MockHttpContext();
            MockHandler     mockHandler = new MockHandler();

            mockContext.Handler = mockHandler;

            application.TestPreRequestHandlerExecute(mockContext);
            Assert.IsTrue(application.PrePageExecuteCalled);

            application.TestPostRequestHandlerExecute(mockContext);
            Assert.IsTrue(application.PostPageExecuteCalled);
        }
Example #11
0
        public void AddServiceOnlyIfMissing()
        {
            TestableWebClientApplication     app       = new TestableWebClientApplication();
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            Foo foo = app.TestAddServiceIfMissing <Foo, IFoo>(container);

            Assert.AreSame(foo, container.Services.Get <IFoo>());

            Foo foo2 = app.TestAddServiceIfMissing <Foo, IFoo>(container);

            Assert.AreNotSame(foo2, container.Services.Get <IFoo>());
            Assert.AreSame(foo, container.Services.Get <IFoo>());
        }
Example #12
0
        public void LoadModulesCallsModuleLoaderService()
        {
            TestableWebClientApplication app = new TestableWebClientApplication();

            app.SetTestRootCompositionContainer(new TestableRootCompositionContainer());

            IModuleLoaderService loaderService =
                app.RootContainer.Services.AddNew <MockModuleLoaderService, IModuleLoaderService>();

            app.RootContainer.Services.AddNew <MockModuleEnumerator, IModuleEnumerator>();

            app.TestLoadModules();

            Assert.IsTrue(((MockModuleLoaderService)loaderService).LoadCalled);
        }
Example #13
0
        public void WebApplicationCreatesBuilderThatDoesContainerAwareTypeMapping()
        {
            TestableWebClientApplication app = new TestableWebClientApplication();
            MockHttpContext context          = new MockHttpContext();

            app.TestRun();

            CompositionContainer root = app.RootContainer;

            root.RegisterTypeMapping <IFoo, Foo>();

            IFoo created = (IFoo)(root.BuildNewItem(typeof(IFoo)));

            Assert.IsNotNull(created);
            Assert.IsTrue(created is Foo);
        }
        public void TestApplicationLifecyleIsExecuted()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();

            application.TestApplicationStart();

            Assert.IsTrue(application.CalledMethods.IndexOf("CreateBuilder") <
                          application.CalledMethods.IndexOf("AddBuilderStrategies"));

            Assert.IsTrue(application.CalledMethods.IndexOf("AddBuilderStrategies") <
                          application.CalledMethods.IndexOf("CreateRootContainer"));

            Assert.IsTrue(application.CalledMethods.IndexOf("CreateRootContainer") <
                          application.CalledMethods.IndexOf("AddRequiredServices"));

            Assert.IsTrue(application.CalledMethods.IndexOf("AddRequiredServices") <
                          application.CalledMethods.IndexOf("LoadModules"));

            Assert.IsTrue(application.CalledMethods.IndexOf("LoadModules") <
                          application.CalledMethods.IndexOf("Start"));
        }
        public void TestApplicationLifecyleIsExecuted()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();

            application.TestApplicationStart();


            Assert.IsTrue(application.CalledMethods.IndexOf("CreateBuilder") <
                          application.CalledMethods.IndexOf("AddBuilderStrategies"));

            Assert.IsTrue(application.CalledMethods.IndexOf("AddBuilderStrategies") <
                          application.CalledMethods.IndexOf("CreateRootContainer"));

            Assert.IsTrue(application.CalledMethods.IndexOf("CreateRootContainer") <
                          application.CalledMethods.IndexOf("AddRequiredServices"));

            Assert.IsTrue(application.CalledMethods.IndexOf("AddRequiredServices") <
                          application.CalledMethods.IndexOf("LoadModules"));

            Assert.IsTrue(application.CalledMethods.IndexOf("LoadModules") <
                          application.CalledMethods.IndexOf("Start"));
        }
Example #16
0
        public void NestedUserControlsAreBuiltCorrectly()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();
            MockHttpContext mockContext = new MockHttpContext();
            MockPage        mockPage    = new MockPage();

            mockContext.Request             = new HttpRequest("page.aspx", "http://application/page.aspx", null);
            mockContext.Handler             = mockPage;
            mockContext.ApplicationInstance = application;
            TestableRootCompositionContainer container = new TestableRootCompositionContainer();

            application.ModuleContainer = container;
            application.SetTestCurrentContext(mockContext);

            application.TestRun();
            mockPage.CallOnInit();
            mockPage.MyControl.CallOnInit();
            mockPage.MyControl.Nested.CallOnInit();

            Assert.IsNotNull(mockPage.Presenter);
            Assert.IsNotNull(mockPage.MyControl.MyControlPresenter);
            Assert.IsNotNull(mockPage.MyControl.Nested.MyControlPresenter);
        }
Example #17
0
        public void TestModulesAreLoadedUsingEnumeratorAndLoaderServices()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();

            application.TestRun();
        }