Ejemplo n.º 1
0
        public void OAuth_ProviderNotFound()
        {
            var oauth = new OAuthManager
            {
                GetProvider      = s => null,
                LoadOrCreateUser = TestUser.Create
            };

            // this must throw an exception, because the provider is null (cannot be found)
            Assert.Throws <InvalidOperationException>(() => oauth.VerifyUser(TestOAuthProvider.TestProviderName, null));
        }
Ejemplo n.º 2
0
        public void OAuth_ValidUser()
        {
            var oauth = new OAuthManager
            {
                GetProvider      = s => new OAuthProviderValid(),
                LoadOrCreateUser = TestUser.Create
            };

            var user = oauth.VerifyUser(TestOAuthProvider.TestProviderName, null);

            Assert.Equal(TestOAuthProvider.UserName, user.Username);
        }
Ejemplo n.º 3
0
        public void OAuth_ProviderError()
        {
            var oauth = new OAuthManager
            {
                GetProvider      = s => new OAuthProviderError(),
                LoadOrCreateUser = TestUser.Create
            };

            // this must return null (we use the OAuthProviderError), even if the LoadOrCreateUser method is defined above
            var user = oauth.VerifyUser(TestOAuthProvider.TestProviderName, null);

            Assert.Null(user);
        }