public void RegisterModuleServicesRegistersICustomersDataSource() { TestableModuleInitializer module = new TestableModuleInitializer(); MockServiceCollection serviceCollection = new MockServiceCollection(); module.TestAddModuleServices(serviceCollection); Assert.IsTrue(serviceCollection.RegistedServices.ContainsKey(typeof(ICustomersDataSource))); }
public void ContactsGetsRegisteredOnSiteMap() { TestableModuleInitializer moduleInitializer = new TestableModuleInitializer(); SiteMapBuilderService siteMapBuilder = new SiteMapBuilderService(); moduleInitializer.TestRegisterSiteMapInformation(siteMapBuilder); SiteMapNodeInfo node = siteMapBuilder.GetChildren(siteMapBuilder.RootNode.Key)[0]; Assert.AreEqual("Contacts", node.Key); }
public void ConfigureShouldNotThrowExceptionIfAuthorizationServicesIsNotLoaded() { MockServiceCollection collection = new MockServiceCollection(); TestableModuleInitializer module = new TestableModuleInitializer(); module.Configure(collection, ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)); MockAuthorizationRulesService authRulesServices = (MockAuthorizationRulesService)collection.Get<IAuthorizationRulesService>(); Assert.IsNull(authRulesServices); }
public void ConfigureShouldNotThrowExceptionIfAuthorizationServicesIsNotLoaded() { MockServiceCollection collection = new MockServiceCollection(); TestableModuleInitializer module = new TestableModuleInitializer(); module.Configure(collection, ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)); MockAuthorizationRulesService authRulesServices = (MockAuthorizationRulesService)collection.Get <IAuthorizationRulesService>(); Assert.IsNull(authRulesServices); }
public void ConfigureShouldRegisterAuthorizationRules() { MockServiceCollection collection = new MockServiceCollection(); collection.Add(typeof(IAuthorizationRulesService), new MockAuthorizationRulesService()); TestableModuleInitializer module = new TestableModuleInitializer(); module.Configure(collection, ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)); MockAuthorizationRulesService authRulesServices = (MockAuthorizationRulesService)collection.Get<IAuthorizationRulesService>(); Assert.AreEqual(1, authRulesServices.RegisteredAuthorizationRules.Count); Assert.IsTrue(authRulesServices.RegisteredAuthorizationRules.ContainsKey("Default.aspx")); Assert.AreEqual("MockRule01", authRulesServices.RegisteredAuthorizationRules["Default.aspx"]); }
public void LoadCallsRegisterSiteMapInformation() { TestableRootCompositionContainer parentContainer = new TestableRootCompositionContainer(); TestableRootCompositionContainer container = parentContainer.Containers.AddNew <TestableRootCompositionContainer>("TEST"); TestableModuleInitializer moduleInitializer = new TestableModuleInitializer(); ISiteMapBuilderService siteMapBuilder = new MockSiteMapBuilderService(); IHttpContextLocatorService contextLocator = new MockHttpContextLocatorService(); container.Services.Add <IHttpContextLocatorService>(contextLocator); container.Services.Add <ISiteMapBuilderService>(siteMapBuilder); moduleInitializer.Load(container); Assert.IsTrue(moduleInitializer.RegisterSiteMapWasCalled); }
public void ConfigureShouldRegisterAuthorizationRules() { MockServiceCollection collection = new MockServiceCollection(); collection.Add(typeof(IAuthorizationRulesService), new MockAuthorizationRulesService()); TestableModuleInitializer module = new TestableModuleInitializer(); module.Configure(collection, ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)); MockAuthorizationRulesService authRulesServices = (MockAuthorizationRulesService)collection.Get <IAuthorizationRulesService>(); Assert.AreEqual(1, authRulesServices.RegisteredAuthorizationRules.Count); Assert.IsTrue(authRulesServices.RegisteredAuthorizationRules.ContainsKey("Default.aspx")); Assert.AreEqual("MockRule01", authRulesServices.RegisteredAuthorizationRules["Default.aspx"]); }
public void LoadCallsRegisterSiteMapInformation() { TestableRootCompositionContainer parentContainer = new TestableRootCompositionContainer(); TestableRootCompositionContainer container = parentContainer.Containers.AddNew<TestableRootCompositionContainer>("TEST"); TestableModuleInitializer moduleInitializer = new TestableModuleInitializer(); ISiteMapBuilderService siteMapBuilder = new MockSiteMapBuilderService(); IHttpContextLocatorService contextLocator = new MockHttpContextLocatorService(); container.Services.Add<IHttpContextLocatorService>(contextLocator); container.Services.Add<ISiteMapBuilderService>(siteMapBuilder); moduleInitializer.Load(container); Assert.IsTrue(moduleInitializer.RegisterSiteMapWasCalled); }