public async void DeleteAsync_UserIdOrganizationId_Works_DataMatches(SsoUser ssoUser,
                                                                             User user, Organization org, 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);
        }
        public async void CreateAsync_Works_DataMatches(SsoUser ssoUser, User user, Organization org,
                                                        SsoUserCompare equalityComparer, List <EfRepo.SsoUserRepository> suts,
                                                        List <EfRepo.OrganizationRepository> efOrgRepos, List <EfRepo.UserRepository> efUserRepos,
                                                        SqlRepo.SsoUserRepository sqlSsoUserRepo, SqlRepo.OrganizationRepository sqlOrgRepo,
                                                        SqlRepo.UserRepository sqlUserRepo)
        {
            var createdSsoUsers = 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();

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

                sut.ClearChangeTracking();

                var savedSsoUser = await sut.GetByIdAsync(ssoUser.Id);

                createdSsoUsers.Add(savedSsoUser);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            var sqlOrganization = await sqlOrgRepo.CreateAsync(org);

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

            createdSsoUsers.Add(await sqlSsoUserRepo.GetByIdAsync(sqlSsoUser.Id));

            var distinctSsoUsers = createdSsoUsers.Distinct(equalityComparer);

            Assert.True(!distinctSsoUsers.Skip(1).Any());
        }
Example #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());
        }