예제 #1
0
        public async void DeleteAsync_Works_DataMatches(User user, UserCompare equalityComparer,
                                                        List <EfRepo.UserRepository> suts, SqlRepo.UserRepository sqlUserRepo)
        {
            foreach (var sut in suts)
            {
                var postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();

                var savedEfUser = await sut.GetByIdAsync(postEfUser.Id);

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

                await sut.DeleteAsync(savedEfUser);

                sut.ClearChangeTracking();

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

                Assert.True(savedEfUser == null);
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(user);

            var savedSqlUser = await sqlUserRepo.GetByIdAsync(postSqlUser.Id);

            Assert.True(savedSqlUser != null);

            await sqlUserRepo.DeleteAsync(postSqlUser);

            savedSqlUser = await sqlUserRepo.GetByIdAsync(postSqlUser.Id);

            Assert.True(savedSqlUser == null);
        }
예제 #2
0
        public async void CreateAsync_Works_DataMatches(
            User user, UserCompare equalityComparer,
            List <EfRepo.UserRepository> suts,
            SqlRepo.UserRepository sqlUserRepo
            )
        {
            var savedUsers = new List <User>();

            foreach (var sut in suts)
            {
                var postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();

                var savedUser = await sut.GetByIdAsync(postEfUser.Id);

                savedUsers.Add(savedUser);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            savedUsers.Add(await sqlUserRepo.GetByIdAsync(sqlUser.Id));

            var distinctItems = savedUsers.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #3
0
        public async void ReplaceAsync_Works_DataMatches(User postUser, User replaceUser,
                                                         UserCompare equalityComparer, List <EfRepo.UserRepository> suts,
                                                         SqlRepo.UserRepository sqlUserRepo)
        {
            var savedUsers = new List <User>();

            foreach (var sut in suts)
            {
                var postEfUser = await sut.CreateAsync(postUser);

                replaceUser.Id = postEfUser.Id;
                await sut.ReplaceAsync(replaceUser);

                var replacedUser = await sut.GetByIdAsync(replaceUser.Id);

                savedUsers.Add(replacedUser);
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(postUser);

            replaceUser.Id = postSqlUser.Id;
            await sqlUserRepo.ReplaceAsync(replaceUser);

            savedUsers.Add(await sqlUserRepo.GetByIdAsync(replaceUser.Id));

            var distinctItems = savedUsers.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #4
0
        public async void UpdateRenewalReminderDateAsync_Works_DataMatches(User user,
                                                                           DateTime updatedReminderDate, List <EfRepo.UserRepository> suts,
                                                                           SqlRepo.UserRepository sqlUserRepo)
        {
            var savedDates = new List <DateTime?>();

            foreach (var sut in suts)
            {
                var postEfUser = user;
                postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();

                await sut.UpdateRenewalReminderDateAsync(postEfUser.Id, updatedReminderDate);

                sut.ClearChangeTracking();

                var replacedUser = await sut.GetByIdAsync(postEfUser.Id);

                savedDates.Add(replacedUser.RenewalReminderDate);
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(user);

            await sqlUserRepo.UpdateRenewalReminderDateAsync(postSqlUser.Id, updatedReminderDate);

            var replacedSqlUser = await sqlUserRepo.GetByIdAsync(postSqlUser.Id);

            savedDates.Add(replacedSqlUser.RenewalReminderDate);

            var distinctItems = savedDates.GroupBy(e => e.ToString());

            Assert.True(!distinctItems.Skip(1).Any() &&
                        savedDates.All(e => e.ToString() == updatedReminderDate.ToString()));
        }
예제 #5
0
        public async void GetKdfInformationByEmailAsync_Works_DataMatches(User user,
                                                                          UserKdfInformationCompare equalityComparer, List <EfRepo.UserRepository> suts,
                                                                          SqlRepo.UserRepository sqlUserRepo)
        {
            var savedKdfInformation = new List <UserKdfInformation>();

            foreach (var sut in suts)
            {
                var postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();
                var kdfInformation = await sut.GetKdfInformationByEmailAsync(postEfUser.Email.ToUpperInvariant());

                savedKdfInformation.Add(kdfInformation);
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(user);

            var sqlKdfInformation = await sqlUserRepo.GetKdfInformationByEmailAsync(postSqlUser.Email);

            savedKdfInformation.Add(sqlKdfInformation);

            var distinctItems = savedKdfInformation.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #6
0
        public async void SearchAsync_Works_DataMatches(User user, int skip, int take,
                                                        UserCompare equalityCompare, List <EfRepo.UserRepository> suts,
                                                        SqlRepo.UserRepository sqlUserRepo)
        {
            var searchedEfUsers = new List <User>();

            foreach (var sut in suts)
            {
                var postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();

                var searchedEfUsersCollection = await sut.SearchAsync(postEfUser.Email.ToUpperInvariant(), skip, take);

                searchedEfUsers.Concat(searchedEfUsersCollection.ToList());
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(user);

            var searchedSqlUsers = await sqlUserRepo.SearchAsync(postSqlUser.Email.ToUpperInvariant(), skip, take);

            var distinctItems = searchedEfUsers.Concat(searchedSqlUsers).Distinct(equalityCompare);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #7
0
        public async void CreateAsync_Works_DataMatches(
            Send send,
            User user,
            Organization org,
            SendCompare equalityComparer,
            List <EfRepo.SendRepository> suts,
            List <EfRepo.UserRepository> efUserRepos,
            List <EfRepo.OrganizationRepository> efOrgRepos,
            SqlRepo.SendRepository sqlSendRepo,
            SqlRepo.UserRepository sqlUserRepo,
            SqlRepo.OrganizationRepository sqlOrgRepo
            )
        {
            var savedSends = new List <Send>();

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

                if (send.OrganizationId.HasValue)
                {
                    var efOrg = await efOrgRepos[i].CreateAsync(org);
                    sut.ClearChangeTracking();
                    send.OrganizationId = efOrg.Id;
                }
                var efUser = await efUserRepos[i].CreateAsync(user);
                sut.ClearChangeTracking();

                send.UserId = efUser.Id;
                var postEfSend = await sut.CreateAsync(send);

                sut.ClearChangeTracking();

                var savedSend = await sut.GetByIdAsync(postEfSend.Id);

                savedSends.Add(savedSend);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            if (send.OrganizationId.HasValue)
            {
                var sqlOrg = await sqlOrgRepo.CreateAsync(org);

                send.OrganizationId = sqlOrg.Id;
            }

            send.UserId = sqlUser.Id;
            var sqlSend = await sqlSendRepo.CreateAsync(send);

            var savedSqlSend = await sqlSendRepo.GetByIdAsync(sqlSend.Id);

            savedSends.Add(savedSqlSend);

            var distinctItems = savedSends.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #8
0
        public async void ReplaceAsync_Works_DataMatches(
            OrganizationUser postOrgUser,
            OrganizationUser replaceOrgUser,
            User user,
            Organization org,
            OrganizationUserCompare equalityComparer,
            List <EfRepo.OrganizationUserRepository> suts,
            List <EfRepo.UserRepository> efUserRepos,
            List <EfRepo.OrganizationRepository> efOrgRepos,
            SqlRepo.OrganizationUserRepository sqlOrgUserRepo,
            SqlRepo.UserRepository sqlUserRepo,
            SqlRepo.OrganizationRepository sqlOrgRepo
            )
        {
            var savedOrgUsers = new List <OrganizationUser>();

            foreach (var sut in suts)
            {
                var i          = suts.IndexOf(sut);
                var postEfUser = await efUserRepos[i].CreateAsync(user);
                var postEfOrg  = await efOrgRepos[i].CreateAsync(org);
                sut.ClearChangeTracking();

                postOrgUser.UserId         = replaceOrgUser.UserId = postEfUser.Id;
                postOrgUser.OrganizationId = replaceOrgUser.OrganizationId = postEfOrg.Id;
                var postEfOrgUser = await sut.CreateAsync(postOrgUser);

                sut.ClearChangeTracking();

                replaceOrgUser.Id = postOrgUser.Id;
                await sut.ReplaceAsync(replaceOrgUser);

                sut.ClearChangeTracking();

                var replacedOrganizationUser = await sut.GetByIdAsync(replaceOrgUser.Id);

                savedOrgUsers.Add(replacedOrganizationUser);
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(user);

            var postSqlOrg = await sqlOrgRepo.CreateAsync(org);

            postOrgUser.UserId         = replaceOrgUser.UserId = postSqlUser.Id;
            postOrgUser.OrganizationId = replaceOrgUser.OrganizationId = postSqlOrg.Id;
            var postSqlOrgUser = await sqlOrgUserRepo.CreateAsync(postOrgUser);

            replaceOrgUser.Id = postSqlOrgUser.Id;
            await sqlOrgUserRepo.ReplaceAsync(replaceOrgUser);

            var replacedSqlUser = await sqlOrgUserRepo.GetByIdAsync(replaceOrgUser.Id);

            var distinctItems = savedOrgUsers.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #9
0
        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(
            EmergencyAccess emergencyAccess,
            List <User> users,
            EmergencyAccessCompare equalityComparer,
            List <EfRepo.EmergencyAccessRepository> suts,
            List <EfRepo.UserRepository> efUserRepos,
            SqlRepo.EmergencyAccessRepository sqlEmergencyAccessRepo,
            SqlRepo.UserRepository sqlUserRepo
            )
        {
            var savedEmergencyAccesss = new List <EmergencyAccess>();

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

                for (int j = 0; j < users.Count; j++)
                {
                    users[j] = await efUserRepos[i].CreateAsync(users[j]);
                }
                sut.ClearChangeTracking();

                emergencyAccess.GrantorId = users[0].Id;
                emergencyAccess.GranteeId = users[0].Id;
                var postEfEmergencyAccess = await sut.CreateAsync(emergencyAccess);

                sut.ClearChangeTracking();

                var savedEmergencyAccess = await sut.GetByIdAsync(postEfEmergencyAccess.Id);

                savedEmergencyAccesss.Add(savedEmergencyAccess);
            }

            for (int j = 0; j < users.Count; j++)
            {
                users[j] = await sqlUserRepo.CreateAsync(users[j]);
            }

            emergencyAccess.GrantorId = users[0].Id;
            emergencyAccess.GranteeId = users[0].Id;
            var sqlEmergencyAccess = await sqlEmergencyAccessRepo.CreateAsync(emergencyAccess);

            var savedSqlEmergencyAccess = await sqlEmergencyAccessRepo.GetByIdAsync(sqlEmergencyAccess.Id);

            savedEmergencyAccesss.Add(savedSqlEmergencyAccess);

            var distinctItems = savedEmergencyAccesss.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #11
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());
        }
예제 #12
0
        public async void CreateAsync_Works_DataMatches(
            U2f u2f,
            User user,
            U2fCompare equalityComparer,
            List <EfRepo.U2fRepository> suts,
            List <EfRepo.UserRepository> efUserRepos,
            SqlRepo.U2fRepository sqlU2fRepo,
            SqlRepo.UserRepository sqlUserRepo
            )
        {
            var savedU2fs = new List <U2f>();

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

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

                u2f.UserId = efUser.Id;
                var postEfU2f = await sut.CreateAsync(u2f);

                sut.ClearChangeTracking();

                var savedU2f = await sut.GetByIdAsync(postEfU2f.Id);

                savedU2fs.Add(savedU2f);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            u2f.UserId = sqlUser.Id;
            var sqlU2f = await sqlU2fRepo.CreateAsync(u2f);

            var savedSqlU2f = await sqlU2fRepo.GetByIdAsync(sqlU2f.Id);

            savedU2fs.Add(savedSqlU2f);

            var distinctItems = savedU2fs.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #13
0
        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());
        }
예제 #14
0
        public async void CreateAsync_Works_DataMatches(Device device, User user,
                                                        DeviceCompare equalityComparer, List <EfRepo.DeviceRepository> suts,
                                                        List <EfRepo.UserRepository> efUserRepos, SqlRepo.DeviceRepository sqlDeviceRepo,
                                                        SqlRepo.UserRepository sqlUserRepo)
        {
            var savedDevices = new List <Device>();

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

                var efUser = await efUserRepos[i].CreateAsync(user);
                device.UserId = efUser.Id;
                sut.ClearChangeTracking();

                var postEfDevice = await sut.CreateAsync(device);

                sut.ClearChangeTracking();

                var savedDevice = await sut.GetByIdAsync(postEfDevice.Id);

                savedDevices.Add(savedDevice);
            }

            var sqlUser = await sqlUserRepo.CreateAsync(user);

            device.UserId = sqlUser.Id;

            var sqlDevice = await sqlDeviceRepo.CreateAsync(device);

            var savedSqlDevice = await sqlDeviceRepo.GetByIdAsync(sqlDevice.Id);

            savedDevices.Add(savedSqlDevice);

            var distinctItems = savedDevices.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
예제 #15
0
        public async void GetAccountRevisionDateAsync(User user, List <EfRepo.UserRepository> suts,
                                                      SqlRepo.UserRepository sqlUserRepo)
        {
            var returnedKeys = new List <string>();

            foreach (var sut in suts)
            {
                var postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();

                var efKey = await sut.GetPublicKeyAsync(postEfUser.Id);

                returnedKeys.Add(efKey);
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(user);

            var sqlKey = await sqlUserRepo.GetPublicKeyAsync(postSqlUser.Id);

            returnedKeys.Add(sqlKey);

            Assert.True(!returnedKeys.Distinct().Skip(1).Any());
        }
예제 #16
0
        public async void GetManyByPremiumAsync_Works_DataMatches(User user,
                                                                  List <EfRepo.UserRepository> suts, SqlRepo.UserRepository sqlUserRepo)
        {
            var returnedUsers = new List <User>();

            foreach (var sut in suts)
            {
                var postEfUser = await sut.CreateAsync(user);

                sut.ClearChangeTracking();

                var searchedEfUsers = await sut.GetManyByPremiumAsync(user.Premium);

                returnedUsers.Concat(searchedEfUsers.ToList());
            }

            var postSqlUser = await sqlUserRepo.CreateAsync(user);

            var searchedSqlUsers = await sqlUserRepo.GetManyByPremiumAsync(user.Premium);

            returnedUsers.Concat(searchedSqlUsers.ToList());

            Assert.True(returnedUsers.All(x => x.Premium == user.Premium));
        }