Beispiel #1
0
        public async void ReplaceAsync_Works_DataMatches(TableModel.Organization postOrganization,
                                                         TableModel.Organization replaceOrganization, SqlRepo.OrganizationRepository sqlOrganizationRepo,
                                                         OrganizationCompare equalityComparer, List <EfRepo.OrganizationRepository> suts)
        {
            var savedOrganizations = new List <TableModel.Organization>();

            foreach (var sut in suts)
            {
                var postEfOrganization = await sut.CreateAsync(postOrganization);

                sut.ClearChangeTracking();

                replaceOrganization.Id = postEfOrganization.Id;
                await sut.ReplaceAsync(replaceOrganization);

                sut.ClearChangeTracking();

                var replacedOrganization = await sut.GetByIdAsync(replaceOrganization.Id);

                savedOrganizations.Add(replacedOrganization);
            }

            var postSqlOrganization = await sqlOrganizationRepo.CreateAsync(postOrganization);

            replaceOrganization.Id = postSqlOrganization.Id;
            await sqlOrganizationRepo.ReplaceAsync(replaceOrganization);

            savedOrganizations.Add(await sqlOrganizationRepo.GetByIdAsync(replaceOrganization.Id));

            var distinctItems = savedOrganizations.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
Beispiel #2
0
        public async void GetByIdentifierAsync_Works_DataMatches(TableModel.Organization organization,
                                                                 SqlRepo.OrganizationRepository sqlOrganizationRepo, OrganizationCompare equalityComparer,
                                                                 List <EfRepo.OrganizationRepository> suts)
        {
            var returnedOrgs = new List <TableModel.Organization>();

            foreach (var sut in suts)
            {
                var postEfOrg = await sut.CreateAsync(organization);

                sut.ClearChangeTracking();

                var returnedOrg = await sut.GetByIdentifierAsync(postEfOrg.Identifier.ToUpperInvariant());

                returnedOrgs.Add(returnedOrg);
            }

            var postSqlOrg = await sqlOrganizationRepo.CreateAsync(organization);

            returnedOrgs.Add(await sqlOrganizationRepo.GetByIdentifierAsync(postSqlOrg.Identifier.ToUpperInvariant()));

            var distinctItems = returnedOrgs.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
Beispiel #3
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());
        }
        public async void ReplaceAsync_Works_DataMatches(
            TableModel.OrganizationUser postOrgUser,
            TableModel.OrganizationUser replaceOrgUser,
            TableModel.User user,
            TableModel.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 <TableModel.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());
        }
        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);
        }
        public async void ReplaceAsync_Works_DataMatches(TableModel.OrganizationSponsorship postOrganizationSponsorship,
                                                         TableModel.OrganizationSponsorship replaceOrganizationSponsorship, TableModel.Organization sponsoringOrg,
                                                         List <EfRepo.OrganizationRepository> efOrgRepos,
                                                         SqlRepo.OrganizationRepository sqlOrganizationRepo,
                                                         SqlRepo.OrganizationSponsorshipRepository sqlOrganizationSponsorshipRepo,
                                                         OrganizationSponsorshipCompare equalityComparer, List <EfRepo.OrganizationSponsorshipRepository> suts)
        {
            postOrganizationSponsorship.InstallationId             = null;
            postOrganizationSponsorship.SponsoredOrganizationId    = null;
            replaceOrganizationSponsorship.InstallationId          = null;
            replaceOrganizationSponsorship.SponsoredOrganizationId = null;

            var savedOrganizationSponsorships = new List <TableModel.OrganizationSponsorship>();

            foreach (var(sut, orgRepo) in suts.Zip(efOrgRepos))
            {
                var efSponsoringOrg = await orgRepo.CreateAsync(sponsoringOrg);

                sut.ClearChangeTracking();
                postOrganizationSponsorship.SponsoringOrganizationId    = efSponsoringOrg.Id;
                replaceOrganizationSponsorship.SponsoringOrganizationId = efSponsoringOrg.Id;

                var postEfOrganizationSponsorship = await sut.CreateAsync(postOrganizationSponsorship);

                sut.ClearChangeTracking();

                replaceOrganizationSponsorship.Id = postEfOrganizationSponsorship.Id;
                await sut.ReplaceAsync(replaceOrganizationSponsorship);

                sut.ClearChangeTracking();

                var replacedOrganizationSponsorship = await sut.GetByIdAsync(replaceOrganizationSponsorship.Id);

                savedOrganizationSponsorships.Add(replacedOrganizationSponsorship);
            }

            var sqlSponsoringOrg = await sqlOrganizationRepo.CreateAsync(sponsoringOrg);

            postOrganizationSponsorship.SponsoringOrganizationId = sqlSponsoringOrg.Id;

            var postSqlOrganization = await sqlOrganizationSponsorshipRepo.CreateAsync(postOrganizationSponsorship);

            replaceOrganizationSponsorship.Id = postSqlOrganization.Id;
            await sqlOrganizationSponsorshipRepo.ReplaceAsync(replaceOrganizationSponsorship);

            savedOrganizationSponsorships.Add(await sqlOrganizationSponsorshipRepo.GetByIdAsync(replaceOrganizationSponsorship.Id));

            var distinctItems = savedOrganizationSponsorships.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
        public async void DeleteAsync_Works_DataMatches(TableModel.OrganizationSponsorship organizationSponsorship,
                                                        TableModel.Organization sponsoringOrg,
                                                        List <EfRepo.OrganizationRepository> efOrgRepos,
                                                        SqlRepo.OrganizationRepository sqlOrganizationRepo,
                                                        SqlRepo.OrganizationSponsorshipRepository sqlOrganizationSponsorshipRepo,
                                                        List <EfRepo.OrganizationSponsorshipRepository> suts)
        {
            organizationSponsorship.InstallationId          = null;
            organizationSponsorship.SponsoredOrganizationId = null;

            foreach (var(sut, orgRepo) in suts.Zip(efOrgRepos))
            {
                var efSponsoringOrg = await orgRepo.CreateAsync(sponsoringOrg);

                sut.ClearChangeTracking();
                organizationSponsorship.SponsoringOrganizationId = efSponsoringOrg.Id;

                var postEfOrganizationSponsorship = await sut.CreateAsync(organizationSponsorship);

                sut.ClearChangeTracking();

                var savedEfOrganizationSponsorship = await sut.GetByIdAsync(postEfOrganizationSponsorship.Id);

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

                await sut.DeleteAsync(savedEfOrganizationSponsorship);

                sut.ClearChangeTracking();

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

                Assert.True(savedEfOrganizationSponsorship == null);
            }

            var sqlSponsoringOrg = await sqlOrganizationRepo.CreateAsync(sponsoringOrg);

            organizationSponsorship.SponsoringOrganizationId = sqlSponsoringOrg.Id;

            var postSqlOrganizationSponsorship = await sqlOrganizationSponsorshipRepo.CreateAsync(organizationSponsorship);

            var savedSqlOrganizationSponsorship = await sqlOrganizationSponsorshipRepo.GetByIdAsync(postSqlOrganizationSponsorship.Id);

            Assert.True(savedSqlOrganizationSponsorship != null);

            await sqlOrganizationSponsorshipRepo.DeleteAsync(postSqlOrganizationSponsorship);

            savedSqlOrganizationSponsorship = await sqlOrganizationSponsorshipRepo.GetByIdAsync(postSqlOrganizationSponsorship.Id);

            Assert.True(savedSqlOrganizationSponsorship == null);
        }
Beispiel #8
0
        public async void ReplaceAsync_Works_DataMatches(SsoConfig postSsoConfig, SsoConfig replaceSsoConfig,
                                                         Organization org, SsoConfigCompare equalityComparer, List <EfRepo.SsoConfigRepository> suts,
                                                         List <EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.SsoConfigRepository sqlSsoConfigRepo,
                                                         SqlRepo.OrganizationRepository sqlOrganizationRepo)
        {
            var savedSsoConfigs = new List <SsoConfig>();

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

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

                postSsoConfig.OrganizationId = replaceSsoConfig.OrganizationId = savedEfOrg.Id;
                var postEfSsoConfig = await sut.CreateAsync(postSsoConfig);

                sut.ClearChangeTracking();

                replaceSsoConfig.Id = postEfSsoConfig.Id;
                savedSsoConfigs.Add(postEfSsoConfig);
                await sut.ReplaceAsync(replaceSsoConfig);

                sut.ClearChangeTracking();

                var replacedSsoConfig = await sut.GetByIdAsync(replaceSsoConfig.Id);

                Assert.True(replacedSsoConfig != null);
                savedSsoConfigs.Add(replacedSsoConfig);
            }

            var sqlOrganization = await sqlOrganizationRepo.CreateAsync(org);

            postSsoConfig.OrganizationId = sqlOrganization.Id;

            var postSqlSsoConfig = await sqlSsoConfigRepo.CreateAsync(postSsoConfig);

            replaceSsoConfig.Id = postSqlSsoConfig.Id;
            savedSsoConfigs.Add(postSqlSsoConfig);

            await sqlSsoConfigRepo.ReplaceAsync(replaceSsoConfig);

            var replacedSqlSsoConfig = await sqlSsoConfigRepo.GetByIdAsync(replaceSsoConfig.Id);

            Assert.True(replacedSqlSsoConfig != null);
            savedSsoConfigs.Add(replacedSqlSsoConfig);

            var distinctItems = savedSsoConfigs.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(2).Any());
        }
Beispiel #9
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());
        }
Beispiel #10
0
        public async void CreateAsync_Works_DataMatches(
            TableModel.Policy policy,
            TableModel.Organization organization,
            PolicyCompare equalityComparer,
            List <EfRepo.PolicyRepository> suts,
            List <EfRepo.OrganizationRepository> efOrganizationRepos,
            SqlRepo.PolicyRepository sqlPolicyRepo,
            SqlRepo.OrganizationRepository sqlOrganizationRepo
            )
        {
            var savedPolicys = new List <TableModel.Policy>();

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

                var efOrganization = await efOrganizationRepos[i].CreateAsync(organization);
                sut.ClearChangeTracking();

                policy.OrganizationId = efOrganization.Id;
                var postEfPolicy = await sut.CreateAsync(policy);

                sut.ClearChangeTracking();

                var savedPolicy = await sut.GetByIdAsync(postEfPolicy.Id);

                savedPolicys.Add(savedPolicy);
            }

            var sqlOrganization = await sqlOrganizationRepo.CreateAsync(organization);

            policy.OrganizationId = sqlOrganization.Id;
            var sqlPolicy = await sqlPolicyRepo.CreateAsync(policy);

            var savedSqlPolicy = await sqlPolicyRepo.GetByIdAsync(sqlPolicy.Id);

            savedPolicys.Add(savedSqlPolicy);

            var distinctItems = savedPolicys.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
Beispiel #11
0
        public async void CreateAsync_Works_DataMatches(
            Collection collection,
            Organization organization,
            CollectionCompare equalityComparer,
            List <EfRepo.CollectionRepository> suts,
            List <EfRepo.OrganizationRepository> efOrganizationRepos,
            SqlRepo.CollectionRepository sqlCollectionRepo,
            SqlRepo.OrganizationRepository sqlOrganizationRepo
            )
        {
            var savedCollections = new List <Collection>();

            foreach (var sut in suts)
            {
                var i = suts.IndexOf(sut);
                var efOrganization = await efOrganizationRepos[i].CreateAsync(organization);
                sut.ClearChangeTracking();

                collection.OrganizationId = efOrganization.Id;
                var postEfCollection = await sut.CreateAsync(collection);

                sut.ClearChangeTracking();

                var savedCollection = await sut.GetByIdAsync(postEfCollection.Id);

                savedCollections.Add(savedCollection);
            }

            var sqlOrganization = await sqlOrganizationRepo.CreateAsync(organization);

            collection.OrganizationId = sqlOrganization.Id;

            var sqlCollection = await sqlCollectionRepo.CreateAsync(collection);

            var savedSqlCollection = await sqlCollectionRepo.GetByIdAsync(sqlCollection.Id);

            savedCollections.Add(savedSqlCollection);

            var distinctItems = savedCollections.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
Beispiel #12
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());
        }
Beispiel #13
0
        public async void GetByIdentifierAsync_Works_DataMatches(SsoConfig ssoConfig, Organization org,
                                                                 SsoConfigCompare equalityComparer, List <EfRepo.SsoConfigRepository> suts,
                                                                 List <EfRepo.OrganizationRepository> efOrgRepos, SqlRepo.SsoConfigRepository sqlSsoConfigRepo,
                                                                 SqlRepo.OrganizationRepository sqlOrgRepo)
        {
            var returnedList = new List <SsoConfig>();

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

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

                ssoConfig.OrganizationId = savedEfOrg.Id;
                await sut.CreateAsync(ssoConfig);

                sut.ClearChangeTracking();

                var savedEfSsoConfig = await sut.GetByIdentifierAsync(org.Identifier);

                Assert.True(savedEfSsoConfig != null);
                returnedList.Add(savedEfSsoConfig);
            }

            var savedSqlOrg = await sqlOrgRepo.CreateAsync(org);

            ssoConfig.OrganizationId = savedSqlOrg.Id;

            var postSqlSsoConfig = await sqlSsoConfigRepo.CreateAsync(ssoConfig);

            var savedSqlSsoConfig = await sqlSsoConfigRepo.GetByIdentifierAsync(org.Identifier);

            Assert.True(savedSqlSsoConfig != null);
            returnedList.Add(savedSqlSsoConfig);

            var distinctItems = returnedList.Distinct(equalityComparer);

            Assert.True(!distinctItems.Skip(1).Any());
        }
Beispiel #14
0
        public async void GetManyByEnabledAsync_Works_DataMatches(TableModel.Organization organization,
                                                                  SqlRepo.OrganizationRepository sqlOrganizationRepo, OrganizationCompare equalityCompare,
                                                                  List <EfRepo.OrganizationRepository> suts)
        {
            var returnedOrgs = new List <TableModel.Organization>();

            foreach (var sut in suts)
            {
                var postEfOrg = await sut.CreateAsync(organization);

                sut.ClearChangeTracking();

                var efReturnedOrgs = await sut.GetManyByEnabledAsync();

                returnedOrgs.Concat(efReturnedOrgs);
            }

            var postSqlOrg = await sqlOrganizationRepo.CreateAsync(organization);

            returnedOrgs.Concat(await sqlOrganizationRepo.GetManyByEnabledAsync());

            Assert.True(returnedOrgs.All(o => o.Enabled));
        }
Beispiel #15
0
        public async void DeleteAsync_Works_DataMatches(TableModel.Organization organization,
                                                        SqlRepo.OrganizationRepository sqlOrganizationRepo, OrganizationCompare equalityComparer,
                                                        List <EfRepo.OrganizationRepository> suts)
        {
            foreach (var sut in suts)
            {
                var postEfOrganization = await sut.CreateAsync(organization);

                sut.ClearChangeTracking();

                var savedEfOrganization = await sut.GetByIdAsync(postEfOrganization.Id);

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

                await sut.DeleteAsync(savedEfOrganization);

                sut.ClearChangeTracking();

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

                Assert.True(savedEfOrganization == null);
            }

            var postSqlOrganization = await sqlOrganizationRepo.CreateAsync(organization);

            var savedSqlOrganization = await sqlOrganizationRepo.GetByIdAsync(postSqlOrganization.Id);

            Assert.True(savedSqlOrganization != null);

            await sqlOrganizationRepo.DeleteAsync(postSqlOrganization);

            savedSqlOrganization = await sqlOrganizationRepo.GetByIdAsync(postSqlOrganization.Id);

            Assert.True(savedSqlOrganization == null);
        }