コード例 #1
0
ファイル: IocConfig.cs プロジェクト: saibalghosh/Layout3
        private static void InitializeContainer(Container container)
        {
            container.RegisterMemberAuthentication();
            container.RegisterSaml();
            container.RegisterConfigurationManager();
            container.RegisterMailSender();
            container.RegisterHttpConsumer();
#if AZURE
            container.RegisterNGeo(
                ConfigurationManager.AppSettings[AppSettingsKey.GeoNamesUserName.ToString()],
                ConfigurationManager.AppSettings[AppSettingsKey.GeoPlanetAppId.ToString()],
                ConfigurationManager.AppSettings[AppSettingsKey.PlaceFinderConsumerKey.ToString()],
                ConfigurationManager.AppSettings[AppSettingsKey.PlaceFinderConsumerSecret.ToString()]);
#else
            container.RegisterNGeo(
                ConfigurationManager.AppSettings[AppSettingsKey.GeoNamesUserName.ToString()],
                ConfigurationManager.AppSettings[AppSettingsKey.GeoPlanetAppId.ToString()]);
#endif
            container.RegisterElmahExceptionLogger();
            container.RegisterBinaryDataStorage();
            container.RegisterEntityFramework();
            container.RegisterFluentValidation(Assembly.GetAssembly(typeof (IHandleCommands<>)));
            container.RegisterQueryProcessor(Assembly.GetAssembly(typeof(IHandleQueries<,>)));
            container.RegisterEventProcessor(Assembly.GetAssembly(typeof(IHandleEvents<>)));
            container.RegisterCommandHandlers(Assembly.GetAssembly(typeof(IHandleCommands<>)));
            container.TryRegisterAzureCacheProvider();
            container.RegisterViewManager();
        }
コード例 #2
0
        public void RegistersIAuthenticationManager_UsingOwin_WhenCurrentHttpContext_HasOwinEnvironment()
        {
            HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null));
            var owinEnvironment = new Dictionary<string, object>();
            var userStore = new Mock<IUserStore<User, int>>();
            var userManager = new UserManager<User, int>(userStore.Object);
            owinEnvironment["AspNet.Identity.Owin:" + userManager.GetType().AssemblyQualifiedName] = userManager;
            HttpContext.Current.Items.Add("owin.Environment", owinEnvironment);
            var container = new Container();
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterEntityFramework();
            container.RegisterSecurity();
            container.Verify();

            var registration = container.GetRegistration(typeof(IAuthenticationManager));
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            var instance = container.GetInstance<IAuthenticationManager>();
            instance.ShouldNotBeNull();
        }
コード例 #3
0
        public void RegistersIAuthenticationManager_UsingBigFatPhony_WhenCurrentHttpContext_IsNull()
        {
            //var registration = Container.GetRegistration(typeof (IAuthenticationManager));
            //registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            //var instance = Container.GetInstance<IAuthenticationManager>();
            //instance.ShouldNotBeNull();
            //instance.ShouldBeType<BigFatPhonyAuthenticationManager>();
            HttpContext.Current = null;
            var container = new Container();
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterEntityFramework();
            container.RegisterSecurity();
            container.Verify();

            var registration = container.GetRegistration(typeof(IAuthenticationManager));
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            var instance = container.GetInstance<IAuthenticationManager>();
            instance.ShouldNotBeNull();
            instance.ShouldBeType<BigFatPhonyAuthenticationManager>();
        }
コード例 #4
0
        public void RegistersIAuthenticationManager_UsingBigFatPhony_WhenCurrentHttpContext_HasNoOwinEnvironment()
        {
            HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null));
            var container = new Container();
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterEntityFramework();
            container.RegisterSecurity();
            container.Verify();

            var registration = container.GetRegistration(typeof(IAuthenticationManager));
            registration.Lifestyle.ShouldEqual(Lifestyle.Transient);
            var instance = container.GetInstance<IAuthenticationManager>();
            instance.ShouldNotBeNull();
            instance.ShouldBeType<BigFatPhonyAuthenticationManager>();
        }
コード例 #5
0
        public void RegistersUserTokenManager_WithOwinTokenProviders()
        {
            HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null));
            var container = new Container();
            container.RegisterConfiguration();
            container.RegisterCryptography();
            container.RegisterEntityFramework();
            container.RegisterSecurity();
            container.Verify();

            var instance = container.GetInstance<UserManager<UserTicket, string>>();
            instance.ShouldNotBeNull();
            instance.UserTokenProvider.ShouldNotBeNull();
        }