Example #1
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 #2
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);
        }