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 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()); }