示例#1
0
        public async void DeleteAsync_Works_DataMatches(Organization organization,
                                                        SqlRepo.OrganizationRepository sqlOrganizationRepo, 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);
        }
示例#2
0
        public async void ReplaceAsync_Works_DataMatches(Organization postOrganization,
                                                         Organization replaceOrganization, SqlRepo.OrganizationRepository sqlOrganizationRepo,
                                                         OrganizationCompare equalityComparer, List <EfRepo.OrganizationRepository> suts)
        {
            var savedOrganizations = new List <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());
        }