Example #1
0
        public async Task CreateGetUpdateDeleteTest()
        {
            const string newIssuerText = "new issuer";

            await Utility.ClearRoleCollection();

            UserRoleDoc testDoc = Utility.CreateUserRoleDoc(0);

            bool status = await Utility.RoleRepository.Set(Utility.Context, testDoc);

            status.Should().BeTrue();

            HeaderDoc <UserRoleDoc> docs = await Utility.RoleRepository.Get(Utility.Context, testDoc.RoleId);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();

            Utility.CompareDocument(testDoc, docs.Payload);

            testDoc.Claims.First().Issuer      = newIssuerText;
            docs.Payload.Claims.First().Issuer = newIssuerText;

            status = await Utility.RoleRepository.Set(Utility.Context, testDoc, docs.ETag);

            status.Should().BeTrue();

            docs = await Utility.RoleRepository.Get(Utility.Context, testDoc.RoleId);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();

            Utility.CompareDocument(testDoc, docs.Payload);
            await DeleteAndVerify(testDoc.RoleId);
        }
Example #2
0
        public async Task CreateGetUpdateDeleteTest()
        {
            const string newEmail = "new email";

            await Utility.ClearUserCollection();

            UserDoc testDoc = Utility.CreateUserDoc(0);

            bool status = await Utility.UserRepository.Set(Utility.Context, testDoc);

            status.Should().BeTrue();

            HeaderDoc <UserDoc> docs = await Utility.UserRepository.Get(Utility.Context, testDoc.UserName);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();

            Utility.CompareDocument(testDoc, docs.Payload);

            testDoc.Email      = newEmail;
            docs.Payload.Email = newEmail;

            status = await Utility.UserRepository.Set(Utility.Context, testDoc, docs.ETag);

            status.Should().BeTrue();

            docs = await Utility.UserRepository.Get(Utility.Context, testDoc.UserName);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();

            Utility.CompareDocument(testDoc, docs.Payload);
            await DeleteAndVerify(testDoc.UserName);
        }
Example #3
0
        public async Task CreateGetUpdateDeleteErrorTest()
        {
            const string newIssuerText = "new issuer";

            await Utility.ClearUserCollection();

            UserDoc testDoc = Utility.CreateUserDoc(0);

            bool status = await Utility.UserRepository.Set(Utility.Context, testDoc);

            status.Should().BeTrue();

            HeaderDoc <UserDoc> docs = await Utility.UserRepository.Get(Utility.Context, testDoc.UserName);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();

            Utility.CompareDocument(testDoc, docs.Payload);

            testDoc.Email      = newIssuerText;
            docs.Payload.Email = newIssuerText;

            status = await Utility.UserRepository.Set(Utility.Context, testDoc, "fake");

            status.Should().BeFalse();

            await Utility.UserRepository.Delete(Utility.Context, testDoc.UserName);
        }
Example #4
0
        public async Task CreateManyGetUpdateDeleteTest()
        {
            const string newIssuerText = "new issuer";
            const int    count         = 11;
            int          index         = Utility.Random.Next(0, count - 1);

            await Utility.ClearRoleCollection();

            List <UserRoleDoc> testDocuments = (await Enumerable.Range(0, count)
                                                .Select(x => Utility.CreateUserRoleDoc(x))
                                                .DoAsync(async x => await Utility.RoleRepository.Set(Utility.Context, x))
                                                ).ToList();

            UserRoleDoc testDoc = testDocuments[index];

            HeaderDoc <UserRoleDoc> docs = await Utility.RoleRepository.Get(Utility.Context, testDoc.RoleId);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();
            Utility.CompareDocument(testDoc, docs.Payload);

            testDoc.Claims.First().Issuer      = newIssuerText;
            docs.Payload.Claims.First().Issuer = newIssuerText;

            bool status = await Utility.RoleRepository.Set(Utility.Context, testDoc, docs.ETag);

            status.Should().BeTrue();

            docs = await Utility.RoleRepository.Get(Utility.Context, testDoc.RoleId);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();
            Utility.CompareDocument(testDoc, docs.Payload);

            foreach (var item in testDocuments)
            {
                await Utility.RoleRepository.Delete(Utility.Context, item.RoleId);
            }

            PageResult <HeaderDoc <UserRoleDoc> > deleteState = await Utility.RoleRepository.List(Utility.Context, new PageRequest(10));

            deleteState.Should().NotBeNull();
            deleteState.Items.Count.Should().Be(0);
        }
Example #5
0
        public async Task CreateAndGetFailTest()
        {
            await Utility.ClearRoleCollection();

            UserRoleDoc testDoc = Utility.CreateUserRoleDoc(0);

            bool status = await Utility.RoleRepository.Set(Utility.Context, testDoc);

            status.Should().BeTrue();

            HeaderDoc <UserRoleDoc> docs = await Utility.RoleRepository.Get(Utility.Context, "fake");

            docs.Should().BeNull();

            await DeleteAndVerify(testDoc.RoleId);
        }
Example #6
0
        public async Task CreateGetDeleteTest()
        {
            await Utility.ClearRoleCollection();

            UserRoleDoc testDoc = Utility.CreateUserRoleDoc(0);

            bool status = await Utility.RoleRepository.Set(Utility.Context, testDoc);

            status.Should().BeTrue();

            HeaderDoc <UserRoleDoc> docs = await Utility.RoleRepository.Get(Utility.Context, testDoc.RoleId);

            docs.Should().NotBeNull();
            docs.ETag.Should().NotBeEmpty();

            Utility.CompareDocument(testDoc, docs.Payload);

            await DeleteAndVerify(testDoc.RoleId);
        }