Exemplo n.º 1
0
        public void TokenProviderDelegate_test()
        {
            //ARRANGE
            var dataProtector = new DpapiDataProtectionProvider().Create("OwinIdentity");
            //ACT
            var del = UserTokenProviderFactory.GetTokenProviderDelegate(typeof(ApplicationUser));
            var r   = del(dataProtector);

            //ASSERT
            Assert.IsInstanceOf(typeof(DataProtectorTokenProvider <,>).MakeGenericType(typeof(ApplicationUser), typeof(string)), r);
        }
        protected override Task InitialiseInternal(IDependencyResolver dependencyResolver)
        {
            dependencyResolver.RegisterFactory(typeof(IUserTokenProvider <,>), t =>
            {
                var genParam      = t.GetGenericArguments();
                var dataProtector = new DpapiDataProtectionProvider().Create("OwinIdentity");
                var del           = UserTokenProviderFactory.GetTokenProviderDelegate(genParam[0]);
                var tokenProvider = del(dataProtector);
                return(tokenProvider);
            }, Lifetime.Transient);

            return(Task.CompletedTask);
        }