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); }
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); }
public void TestRootContainerCreatedByCreateRootContainer() { TestableWebClientApplication application = new TestableWebClientApplication(); application.TestRun(); Assert.IsTrue(application.RooContainerCreated); Assert.IsNotNull(application.RootContainer); }
public void TestPageBuilderIsCreatedByCreatePageBuilder() { TestableWebClientApplication application = new TestableWebClientApplication(); application.TestRun(); Assert.IsTrue(application.PageBuilderCreated); Assert.IsNotNull(application.PageBuilder); }
public void AddRequiredServicesAddsModuleContainerLocatorService() { TestableWebClientApplication app = new TestableWebClientApplication(); TestableRootCompositionContainer container = new TestableRootCompositionContainer(); app.SetTestRootCompositionContainer(container); app.TestAddRequiredServices(); container.Services.Contains <ModuleContainerLocatorService>(); }
public void AddRequiredServicesAddsWebConfigModuleInfoStore() { TestableWebClientApplication app = new TestableWebClientApplication(); TestableRootCompositionContainer container = new TestableRootCompositionContainer(); app.SetTestRootCompositionContainer(container); app.TestAddRequiredServices(); container.Services.Contains <WebConfigModuleInfoStore>(); }
public void AddRequiredServicesAddsAuthorizationRulesService() { TestableWebClientApplication app = new TestableWebClientApplication(); TestableRootCompositionContainer container = new TestableRootCompositionContainer(); app.SetTestRootCompositionContainer(container); app.TestAddRequiredServices(); container.Services.Contains <AuthorizationRulesService>(); }
public void AddRequiredServicesAddsVirtualPathUtilityService() { TestableWebClientApplication app = new TestableWebClientApplication(); TestableRootCompositionContainer container = new TestableRootCompositionContainer(); app.SetTestRootCompositionContainer(container); app.TestAddRequiredServices(); container.Services.Contains <VirtualPathUtilityService>(); }
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); }
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); }
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>()); }
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); }
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")); }
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); }
public void TestModulesAreLoadedUsingEnumeratorAndLoaderServices() { TestableWebClientApplication application = new TestableWebClientApplication(); application.TestRun(); }