diff --git a/test/Infrastructure.EFIntegration.Test/Dirt/Repositories/OrganizationReportRepositoryTests.cs b/test/Infrastructure.EFIntegration.Test/Dirt/Repositories/OrganizationReportRepositoryTests.cs index f32c14cf0c..dd2adc0970 100644 --- a/test/Infrastructure.EFIntegration.Test/Dirt/Repositories/OrganizationReportRepositoryTests.cs +++ b/test/Infrastructure.EFIntegration.Test/Dirt/Repositories/OrganizationReportRepositoryTests.cs @@ -64,142 +64,6 @@ public class OrganizationReportRepositoryTests Assert.True(nextSetOfRecords.Count == 1 && nextSetOfRecords.First().OrganizationId == secondOrg.Id); } - [CiSkippedTheory, EfOrganizationReportAutoData] - public async Task ReplaceQuery_Works( - List suts, - List efOrganizationRepos, - OrganizationReportRepository sqlOrganizationReportRepo, - SqlRepo.OrganizationRepository sqlOrganizationRepo) - { - var (org, record) = await CreateOrganizationAndReportAsync(sqlOrganizationRepo, sqlOrganizationReportRepo); - var exampleData = "http://www.example.com"; - var exampleRevisionDate = new DateTime(2021, 1, 1); - var dbRecords = new List(); - - foreach (var sut in suts) - { - var i = suts.IndexOf(sut); - - // create a new organization for each repository - var organization = await efOrganizationRepos[i].CreateAsync(org); - - // map the organization Id and create the PasswordHealthReportApp record - record.OrganizationId = organization.Id; - var organizationReportRecord = await sut.CreateAsync(record); - - // update the record with new values - organizationReportRecord.ReportData = exampleData; - organizationReportRecord.RevisionDate = exampleRevisionDate; - - // apply update to the database - await sut.ReplaceAsync(organizationReportRecord); - sut.ClearChangeTracking(); - - // retrieve the data and add to the list for assertions - var recordFromDb = await sut.GetByIdAsync(organizationReportRecord.Id); - sut.ClearChangeTracking(); - - dbRecords.Add(recordFromDb); - } - - // sql - create a new organization and PasswordHealthReportApplication record - var (sqlOrg, sqlPwdRecord) = await CreateOrganizationAndReportAsync(sqlOrganizationRepo, sqlOrganizationReportRepo); - var sqlOrganizationReportRecord = await sqlOrganizationReportRepo.GetByIdAsync(sqlPwdRecord.Id); - - // sql - update the record with new values - sqlOrganizationReportRecord.ReportData = exampleData; - sqlOrganizationReportRecord.RevisionDate = exampleRevisionDate; - await sqlOrganizationReportRepo.ReplaceAsync(sqlOrganizationReportRecord); - - // sql - retrieve the data and add to the list for assertions - var sqlDbRecord = await sqlOrganizationReportRepo.GetByIdAsync(sqlOrganizationReportRecord.Id); - dbRecords.Add(sqlDbRecord); - - // assertions - // the Guids must be distinct across all records - Assert.True(dbRecords.Select(_ => _.Id).Distinct().Count() == dbRecords.Count); - - // the Uri and RevisionDate must match the updated values - Assert.True(dbRecords.All(_ => _.ReportData == exampleData && _.RevisionDate == exampleRevisionDate)); - } - - [CiSkippedTheory, EfOrganizationReportAutoData] - public async Task Upsert_Works( - List suts, - List efOrganizationRepos, - OrganizationReportRepository sqlOrganizationReportRepo, - SqlRepo.OrganizationRepository sqlOrganizationRepo) - { - var fixture = new Fixture(); - var rawOrg = fixture.Build().Create(); - var rawRecord = fixture.Build() - .With(_ => _.OrganizationId, rawOrg.Id) - .Without(_ => _.Id) - .Create(); - var exampleData = "http://www.example.com"; - var exampleRevisionDate = new DateTime(2021, 1, 1); - var dbRecords = new List(); - - foreach (var sut in suts) - { - var i = suts.IndexOf(sut); - - // create a new organization for each repository - var organization = await efOrganizationRepos[i].CreateAsync(rawOrg); - - // map the organization Id and use Upsert to save new record - rawRecord.OrganizationId = organization.Id; - rawRecord.Id = default(Guid); - await sut.UpsertAsync(rawRecord); - sut.ClearChangeTracking(); - - // retrieve the data and add to the list for assertions - var organizationReportRecord = await sut.GetByIdAsync(rawRecord.Id); - - // update the record with new values - organizationReportRecord.ReportData = exampleData; - organizationReportRecord.RevisionDate = exampleRevisionDate; - - // apply update using Upsert to make changes to db - await sut.UpsertAsync(organizationReportRecord); - sut.ClearChangeTracking(); - - // retrieve the data and add to the list for assertions - var recordFromDb = await sut.GetByIdAsync(organizationReportRecord.Id); - dbRecords.Add(recordFromDb); - - sut.ClearChangeTracking(); - } - - // sql - create new records - var organizationForSql = fixture.Create(); - var sqlOrganizationReportRecord = fixture.Build() - .With(_ => _.OrganizationId, organizationForSql.Id) - .Without(_ => _.Id) - .Create(); - - // sql - use Upsert to insert this data - var sqlOrganization = await sqlOrganizationRepo.CreateAsync(organizationForSql); - await sqlOrganizationReportRepo.UpsertAsync(sqlOrganizationReportRecord); - var sqlPasswordHealthReportApplicationRecord = await sqlOrganizationReportRepo.GetByIdAsync(sqlOrganizationReportRecord.Id); - - // sql - update the record with new values - sqlPasswordHealthReportApplicationRecord.ReportData = exampleData; - sqlPasswordHealthReportApplicationRecord.RevisionDate = exampleRevisionDate; - await sqlOrganizationReportRepo.UpsertAsync(sqlPasswordHealthReportApplicationRecord); - - // sql - retrieve the data and add to the list for assertions - var sqlDbRecord = await sqlOrganizationReportRepo.GetByIdAsync(sqlPasswordHealthReportApplicationRecord.Id); - dbRecords.Add(sqlDbRecord); - - // assertions - // the Guids must be distinct across all records - Assert.True(dbRecords.Select(_ => _.Id).Distinct().Count() == dbRecords.Count); - - // the Uri and RevisionDate must match the updated values - Assert.True(dbRecords.All(_ => _.ReportData == exampleData && _.RevisionDate == exampleRevisionDate)); - } - [CiSkippedTheory, EfOrganizationReportAutoData] public async Task Delete_Works( List suts,