Ejemplo n.º 1
0
        public async void DeleteAsync_UserIdOrganizationId_Works_DataMatches(SsoUser ssoUser,
                                                                             User user, Organization org, SsoUserCompare equalityComparer, List <EfRepo.SsoUserRepository> suts,
                                                                             List <EfRepo.UserRepository> efUserRepos, List <EfRepo.OrganizationRepository> efOrgRepos,
                                                                             SqlRepo.SsoUserRepository sqlSsoUserRepo, SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo
                                                                             )
        {
            foreach (var sut in suts)
            {
                var i = suts.IndexOf(sut);

                var savedEfUser = await efUserRepos[i].CreateAsync(user);
                var savedEfOrg  = await efOrgRepos[i].CreateAsync(org);
                sut.ClearChangeTracking();

                ssoUser.UserId         = savedEfUser.Id;
                ssoUser.OrganizationId = savedEfOrg.Id;
                var postEfSsoUser = await sut.CreateAsync(ssoUser);

                sut.ClearChangeTracking();

                var savedEfSsoUser = await sut.GetByIdAsync(postEfSsoUser.Id);

                Assert.True(savedEfSsoUser != null);
                sut.ClearChangeTracking();

                await sut.DeleteAsync(savedEfSsoUser.UserId, savedEfSsoUser.OrganizationId);

                sut.ClearChangeTracking();

                savedEfSsoUser = await sut.GetByIdAsync(savedEfSsoUser.Id);

                Assert.True(savedEfSsoUser == null);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            var sqlOrganization = await sqlOrgRepo.CreateAsync(org);

            ssoUser.UserId         = sqlUser.Id;
            ssoUser.OrganizationId = sqlOrganization.Id;

            var postSqlSsoUser = await sqlSsoUserRepo.CreateAsync(ssoUser);

            var savedSqlSsoUser = await sqlSsoUserRepo.GetByIdAsync(postSqlSsoUser.Id);

            Assert.True(savedSqlSsoUser != null);

            await sqlSsoUserRepo.DeleteAsync(savedSqlSsoUser.UserId, savedSqlSsoUser.OrganizationId);

            savedSqlSsoUser = await sqlSsoUserRepo.GetByIdAsync(postSqlSsoUser.Id);

            Assert.True(savedSqlSsoUser == null);
        }
Ejemplo n.º 2
0
        public async void ReplaceAsync_Works_DataMatches(SsoUser postSsoUser, SsoUser replaceSsoUser,
                                                         Organization org, User user, SsoUserCompare equalityComparer,
                                                         List <EfRepo.SsoUserRepository> suts, List <EfRepo.UserRepository> efUserRepos,
                                                         List <EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.SsoUserRepository sqlSsoUserRepo,
                                                         SqlRepo.OrganizationRepository sqlOrgRepo, SqlRepo.UserRepository sqlUserRepo)
        {
            var savedSsoUsers = new List <SsoUser>();

            foreach (var sut in suts)
            {
                var i = suts.IndexOf(sut);

                var efUser = await efUserRepos[i].CreateAsync(user);
                var efOrg  = await efOrgRepos[i].CreateAsync(org);
                sut.ClearChangeTracking();

                postSsoUser.UserId         = efUser.Id;
                postSsoUser.OrganizationId = efOrg.Id;
                var postEfSsoUser = await sut.CreateAsync(postSsoUser);

                sut.ClearChangeTracking();

                replaceSsoUser.Id             = postEfSsoUser.Id;
                replaceSsoUser.UserId         = postEfSsoUser.UserId;
                replaceSsoUser.OrganizationId = postEfSsoUser.OrganizationId;
                await sut.ReplaceAsync(replaceSsoUser);

                sut.ClearChangeTracking();

                var replacedSsoUser = await sut.GetByIdAsync(replaceSsoUser.Id);

                savedSsoUsers.Add(replacedSsoUser);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            var sqlOrganization = await sqlOrgRepo.CreateAsync(org);

            postSsoUser.UserId         = sqlUser.Id;
            postSsoUser.OrganizationId = sqlOrganization.Id;
            var postSqlSsoUser = await sqlSsoUserRepo.CreateAsync(postSsoUser);

            replaceSsoUser.Id             = postSqlSsoUser.Id;
            replaceSsoUser.UserId         = postSqlSsoUser.UserId;
            replaceSsoUser.OrganizationId = postSqlSsoUser.OrganizationId;
            await sqlSsoUserRepo.ReplaceAsync(replaceSsoUser);

            savedSsoUsers.Add(await sqlSsoUserRepo.GetByIdAsync(replaceSsoUser.Id));

            var distinctItems = savedSsoUsers.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
Ejemplo n.º 3
0
        public async void GetBySsoUserAsync_Works_DataMatches(User user, Organization org,
                                                              SsoUser ssoUser, UserCompare equalityComparer, List <EfRepo.UserRepository> suts,
                                                              List <EfRepo.SsoUserRepository> ssoUserRepos, List <EfRepo.OrganizationRepository> orgRepos,
                                                              SqlRepo.UserRepository sqlUserRepo, SqlRepo.SsoUserRepository sqlSsoUserRepo,
                                                              SqlRepo.OrganizationRepository sqlOrgRepo)
        {
            var returnedList = new List <User>();

            foreach (var sut in suts)
            {
                var i = suts.IndexOf(sut);

                var postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();

                var efOrg = await orgRepos[i].CreateAsync(org);
                sut.ClearChangeTracking();

                ssoUser.UserId         = postEfUser.Id;
                ssoUser.OrganizationId = efOrg.Id;
                var postEfSsoUser = await ssoUserRepos[i].CreateAsync(ssoUser);
                sut.ClearChangeTracking();

                var returnedUser = await sut.GetBySsoUserAsync(postEfSsoUser.ExternalId.ToUpperInvariant(), efOrg.Id);

                returnedList.Add(returnedUser);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            var sqlOrganization = await sqlOrgRepo.CreateAsync(org);

            ssoUser.UserId         = sqlUser.Id;
            ssoUser.OrganizationId = sqlOrganization.Id;
            var postSqlSsoUser = await sqlSsoUserRepo.CreateAsync(ssoUser);

            var returnedSqlUser = await sqlUserRepo
                                  .GetBySsoUserAsync(postSqlSsoUser.ExternalId, sqlOrganization.Id);

            returnedList.Add(returnedSqlUser);

            var distinctItems = returnedList.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }