Ejemplo n.º 1
0
        public async Task TestRevokeAsync()
        {
            var store         = new ConsentStore();
            var insertClients = await CassandraTestHelper.InsertTestData_Clients(2);

            // we are going to associate a bunch of tokens to this one client
            var subject = Guid.NewGuid().ToString();

            foreach (var client in insertClients)
            {
                await CassandraTestHelper.InsertTestData_Consents(client.ClientId, subject, 1);
            }

            var result = await store.LoadAllAsync(subject);

            Assert.AreEqual(2, result.Count());

            foreach (var client in insertClients)
            {
                await store.RevokeAsync(subject, client.ClientId);
            }
            result = await store.LoadAllAsync(subject);

            Assert.AreEqual(0, result.Count());
        }
        public void TestLoadAllAsync()
        {
            var result = _consentStore.LoadAllAsync("SUBJECT:0");

            Assert.AreEqual(result.Result.Count(), 10);
            foreach (var item in result.Result)
            {
                Assert.AreEqual(item.Subject, "SUBJECT:0");
            }
        }
        public async Task LoadAllAsync()
        {
            string subjectToGet = "subject1";

            //Arrange
            var sut          = new ConsentStore(NhibernateSession);
            var testConsent1 = ObjectCreator.GetConsent(null, subjectToGet);
            var testConsent2 = ObjectCreator.GetConsent(null, subjectToGet);
            var testConsent3 = ObjectCreator.GetConsent();

            ExecuteInTransaction(session =>
            {
                session.Save(testConsent1);
                session.Save(testConsent2);
                session.Save(testConsent3);
            });

            //Act
            var result = (await sut.LoadAllAsync(subjectToGet))
                         .ToList();

            //Assert
            Assert.NotNull(result);
            Assert.True(result.All(c => c.Subject.Equals(subjectToGet)));

            //CleanUp
            ExecuteInTransaction(session =>
            {
                session.Delete(testConsent1);
                session.Delete(testConsent2);
                session.Delete(testConsent3);
            });
        }