public void RegisterModuleServicesRegistersNoServices()
        {
            TestableCustomersModuleInitializer module = new TestableCustomersModuleInitializer();
            MockServiceCollection serviceCollection   = new MockServiceCollection();

            module.TestAddModuleServices(serviceCollection);

            Assert.AreEqual(0, serviceCollection.RegistedServices.Count);
        }
        public void CustomersActionsGetsRegisteredOnSiteMap()
        {
            TestableCustomersModuleInitializer moduleInitializer = new TestableCustomersModuleInitializer();
            SiteMapBuilderService siteMapBuilder = new SiteMapBuilderService();

            moduleInitializer.TestRegisterSiteMapInformation(siteMapBuilder);

            SiteMapNodeInfo nodeSearchOrder = siteMapBuilder.GetChildren("Customers")[0];

            Assert.AreEqual("SearchCustomer", nodeSearchOrder.Key);
        }
        public void ConfigureShouldNotThrowExceptionIfAuthorizationServicesIsNotLoaded()
        {
            MockServiceCollection collection = new MockServiceCollection();

            TestableCustomersModuleInitializer module = new TestableCustomersModuleInitializer();
            module.Configure(collection, ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None));

            MockAuthorizationRulesService authRulesServices =
                (MockAuthorizationRulesService)collection.Get<IAuthorizationRulesService>();

            Assert.IsNull(authRulesServices);
        }
        public void ConfigureShouldNotThrowExceptionIfAuthorizationServicesIsNotLoaded()
        {
            MockServiceCollection collection = new MockServiceCollection();

            TestableCustomersModuleInitializer module = new TestableCustomersModuleInitializer();

            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());

            TestableCustomersModuleInitializer module = new TestableCustomersModuleInitializer();
            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");

            TestableCustomersModuleInitializer moduleInitializer = new TestableCustomersModuleInitializer();

            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());

            TestableCustomersModuleInitializer module = new TestableCustomersModuleInitializer();

            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 CustomersActionsGetsRegisteredOnSiteMap()
        {
            TestableCustomersModuleInitializer moduleInitializer = new TestableCustomersModuleInitializer();
            SiteMapBuilderService siteMapBuilder = new SiteMapBuilderService();

            moduleInitializer.TestRegisterSiteMapInformation(siteMapBuilder);

            SiteMapNodeInfo nodeSearchOrder = siteMapBuilder.GetChildren("Customers")[0];
            Assert.AreEqual("SearchCustomer", nodeSearchOrder.Key);
        }
        public void RegisterModuleServicesRegistersNoServices()
        {
            TestableCustomersModuleInitializer module = new TestableCustomersModuleInitializer();
            MockServiceCollection serviceCollection = new MockServiceCollection();

            module.TestAddModuleServices(serviceCollection);

            Assert.AreEqual(0, serviceCollection.RegistedServices.Count);
        }
        public void LoadCallsRegisterSiteMapInformation()
        {
            TestableRootCompositionContainer parentContainer = new TestableRootCompositionContainer();
            TestableRootCompositionContainer container = parentContainer.Containers.AddNew<TestableRootCompositionContainer>("TEST");

            TestableCustomersModuleInitializer moduleInitializer = new TestableCustomersModuleInitializer();

            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);
        }