Exemplo n.º 1
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();
        }
Exemplo n.º 2
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>();
        }
Exemplo n.º 3
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>();
        }
Exemplo n.º 4
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();
        }