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 TestRootContainerCreatedByCreateRootContainer()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();

            application.TestRun();

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

            application.TestRun();

            Assert.IsTrue(application.PageBuilderCreated);
            Assert.IsNotNull(application.PageBuilder);
        }
Example #4
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);
        }
Example #5
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 #6
0
        public void TestModulesAreLoadedUsingEnumeratorAndLoaderServices()
        {
            TestableWebClientApplication application = new TestableWebClientApplication();

            application.TestRun();
        }