public void TestRevokeAsync()
        {
            var insert   = InsertTestData(_clientStore, _scopeStore, _authorizationCodeHandleStore, _tokenHandleStore, 10);
            var key      = insert[0].Record.Key;
            var clientId = insert[0].Record.ClientId;

            var result = _authorizationCodeHandleStore.GetAsync(key);

            Assert.IsNotNull(result.Result);
            Assert.AreEqual(result.Result.ClientId, clientId);
            var subjectId = result.Result.SubjectId;



            _authorizationCodeHandleStore.RevokeAsync(subjectId, clientId);
            result = _authorizationCodeHandleStore.GetAsync(key);
            Assert.IsNull(result.Result);
        }
        public async Task TestRevokeAsync()
        {
            var insert = await CassandraTestHelper.InsertTestData_AuthorizationCode(10);

            var subjectId = insert[0].SubjectId;
            var clientId  = insert[0].ClientId;
            IAuthorizationCodeStore authStore = new AuthorizationCodeStore();
            var find_metadata = await authStore.GetAllAsync(subjectId);

            Assert.AreEqual(find_metadata.Count(), insert.Count);



            await authStore.RevokeAsync(subjectId, clientId);

            find_metadata = await authStore.GetAllAsync(subjectId);

            Assert.AreEqual(find_metadata.Count(), 0);
        }
        public void RevokeAsync_WhenCalled_ExpectThrows()
        {
            // Arrange
            var mockCacheManager = new Mock<ICacheManager<AuthorizationCode>>();
            var mockCacheConfiguration = new Mock<IConfiguration<RedisCacheConfigurationEntity>>();

            mockCacheConfiguration.Setup(r => r.Get).Returns(new RedisCacheConfigurationEntity { CacheDuration = 1 });

            var authorizationCodeStore = new AuthorizationCodeStore(
                mockCacheManager.Object,
                mockCacheConfiguration.Object);

            // Act and Assert
            var stopwatch = Stopwatch.StartNew();

            Assert.Throws<NotImplementedException>(
                () => authorizationCodeStore.RevokeAsync("string", "string").GetAwaiter().GetResult());

            stopwatch.Stop();
            this.WriteTimeElapsed(stopwatch);
        }
        public async Task RevokeAsync()
        {
            //Arrange
            var sut = new AuthorizationCodeStore(NhibernateSession, ScopeStoreMock.Object, ClientStoreMock.Object);
            var subjectIdToRevoke = Guid.NewGuid().ToString();
            var clientIdToRevoke  = Guid.NewGuid().ToString();

            var testKey  = Guid.NewGuid().ToString();
            var testCode = ObjectCreator.GetAuthorizationCode();

            var nhCode = new Token
            {
                Key       = testKey,
                SubjectId = testCode.SubjectId,
                ClientId  = testCode.ClientId,
                JsonCode  = ConvertToJson(testCode),
                Expiry    = DateTime.UtcNow.AddSeconds(testCode.Client.AuthorizationCodeLifetime),
                TokenType = TokenType.AuthorizationCode
            };

            var testKeyToRevoke  = Guid.NewGuid().ToString();
            var testCodeToRevoke = ObjectCreator.GetAuthorizationCode(subjectIdToRevoke, clientIdToRevoke);

            var nhCodeToRevoke = new Token
            {
                Key       = testKeyToRevoke,
                SubjectId = testCodeToRevoke.SubjectId,
                ClientId  = testCodeToRevoke.ClientId,
                JsonCode  = ConvertToJson(testCodeToRevoke),
                Expiry    = DateTime.UtcNow.AddSeconds(testCodeToRevoke.Client.AuthorizationCodeLifetime),
                TokenType = TokenType.AuthorizationCode
            };

            ExecuteInTransaction(session =>
            {
                session.Save(nhCode);
                session.Save(nhCodeToRevoke);
            });

            //Act
            await sut.RevokeAsync(subjectIdToRevoke, clientIdToRevoke);


            ExecuteInTransaction(session =>
            {
                //Assert
                var tokenRevoked = session.Query <Token>()
                                   .SingleOrDefault(t => t.TokenType == TokenType.AuthorizationCode &&
                                                    t.Key == testKeyToRevoke);

                var tokenNotRevoked = session.Query <Token>()
                                      .SingleOrDefault(t => t.TokenType == TokenType.AuthorizationCode &&
                                                       t.Key == testKey);

                Assert.Null(tokenRevoked);
                Assert.NotNull(tokenNotRevoked);

                //CleanUp
                session.Delete(tokenNotRevoked);
            });
        }