public void RegisterTranslatorsRegistersFourTranslators()
        {
            TestableEFTModuleInitializer module            = new TestableEFTModuleInitializer();
            MockEntityTranslatorService  translatorService = new MockEntityTranslatorService();

            module.TestRegisterTranslators(translatorService);

            Assert.AreEqual(4, translatorService.RegisteredTranslators.Count);
            Assert.AreEqual(translatorService.RegisteredTranslators[0].GetType(), typeof(AccountTranslator));
        }
        public void RegisterModuleServicesRegistrersOneServiceThatIsIAccountServiceAgent()
        {
            TestableEFTModuleInitializer module            = new TestableEFTModuleInitializer();
            MockServiceCollection        serviceCollection = new MockServiceCollection();

            module.TestAddModuleServices(serviceCollection);

            Assert.AreEqual(1, serviceCollection.RegistedServices.Keys.Count);
            Assert.IsTrue(serviceCollection.RegistedServices.ContainsKey(typeof(IAccountServiceAgent)));
        }
        public void RegisterSiteMapInformationRegistersOneNodeWithOneChild()
        {
            TestableEFTModuleInitializer module = new TestableEFTModuleInitializer();
            SiteMapBuilderService        siteMapBuilderService = new SiteMapBuilderService();

            module.TestRegisterSiteMapInformation(siteMapBuilderService);

            ReadOnlyCollection <SiteMapNodeInfo> nodes = siteMapBuilderService.GetChildren(siteMapBuilderService.RootNode.Key);

            Assert.AreEqual(1, nodes.Count);
            Assert.AreEqual(1, siteMapBuilderService.GetChildren(nodes[0].Key).Count);
        }
        public void ConfigureShouldNotThrowExceptionIfAuthorizationServicesIsNotLoaded()
        {
            MockServiceCollection collection = new MockServiceCollection();

            TestableEFTModuleInitializer module = new TestableEFTModuleInitializer();

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

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

            Assert.IsNull(authRulesServices);
        }
        public void RegisterRequiredPermissionsRegistersOnePermissionSetWithTwoActions()
        {
            TestableEFTModuleInitializer module            = new TestableEFTModuleInitializer();
            MockPermissionCatalog        permissionCatalog = new MockPermissionCatalog();

            module.TestRegisterRequiredPermissions(permissionCatalog);

            Assert.AreEqual(1, permissionCatalog.RegisteredPermissions.Count);
            Assert.AreEqual("Electronic Funds Transfers", permissionCatalog.RegisteredSet.ModuleName);
            Assert.AreEqual(1, permissionCatalog.RegisteredSet.Actions.Count);

            List <Microsoft.Practices.CompositeWeb.Authorization.Action> actions = new List <Microsoft.Practices.CompositeWeb.Authorization.Action>(permissionCatalog.RegisteredSet.Actions);

            Assert.IsTrue(actions.Exists(delegate(Microsoft.Practices.CompositeWeb.Authorization.Action action) { return(action.RuleName == Permissions.AllowCreateTransfers); }));
        }
        public void ConfigureShouldRegisterAuthorizationRules()
        {
            MockServiceCollection collection = new MockServiceCollection();

            collection.Add(typeof(IAuthorizationRulesService), new MockAuthorizationRulesService());

            TestableEFTModuleInitializer module = new TestableEFTModuleInitializer();

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