public async Task LoadRegulatoryReportingUnits_SimpleLoad() { OrganizationsDim organization; RegulatoryOverlayDim regulatoryOverlay; ReportingUnitsDim reportingUnit; DateDim date; RegulatoryReportingUnits regulatoryReportingUnit; using (var db = new WaDEContext(Configuration.GetConfiguration())) { organization = await OrganizationsDimBuilder.Load(db); regulatoryOverlay = await RegulatoryOverlayDimBuilder.Load(db); reportingUnit = await ReportingUnitsDimBuilder.Load(db); date = await DateDimBuilder.Load(db); regulatoryReportingUnit = RegulatoryReportingUnitBuilder.Create(new RegulatoryReportingUnitBuilderOptions { Organization = organization, RegulatoryOverlay = regulatoryOverlay, ReportingUnit = reportingUnit, DatePublication = date }); } var sut = CreateWaterAllocationAccessor(); var result = await sut.LoadRegulatoryReportingUnits((new Faker()).Random.AlphaNumeric(10), new[] { regulatoryReportingUnit }); result.Should().BeTrue(); using (var db = new WaDEContext(Configuration.GetConfiguration())) { var dbRegulatoryReportingUnit = await db.RegulatoryReportingUnitsFact.SingleAsync(); dbRegulatoryReportingUnit.DataPublicationDateId.Should().Be(date.DateId); dbRegulatoryReportingUnit.OrganizationId.Should().Be(organization.OrganizationId); dbRegulatoryReportingUnit.RegulatoryOverlayId.Should().Be(regulatoryOverlay.RegulatoryOverlayId); dbRegulatoryReportingUnit.ReportingUnitId.Should().Be(reportingUnit.ReportingUnitId); db.ImportErrors.Should().HaveCount(0); } }
public async Task LoadWaterAllocation_LoadAggBridge_PrimaryUseCategoryCV_Null() { OrganizationsDim organization; ReportingUnitsDim reportingUnit; VariablesDim variable; WaterSourcesDim waterSource; MethodsDim method; DateDim dataPublicationDate; DateDim allocationPriorityDate; AggregatedAmount aggregateAmount; BeneficialUsesCV beneficialUsesCV; using (var db = new WaDEContext(Configuration.GetConfiguration())) { organization = await OrganizationsDimBuilder.Load(db); reportingUnit = await ReportingUnitsDimBuilder.Load(db); variable = await VariablesDimBuilder.Load(db); waterSource = await WaterSourcesDimBuilder.Load(db); method = await MethodsDimBuilder.Load(db); dataPublicationDate = await DateDimBuilder.Load(db); allocationPriorityDate = await DateDimBuilder.Load(db); beneficialUsesCV = await BeneficalUsesBuilder.Load(db); aggregateAmount = AggregatedAmountBuilder.Create(); aggregateAmount.PrimaryUseCategory = null; aggregateAmount.ReportingUnitUUID = reportingUnit.ReportingUnitUuid; aggregateAmount.BeneficialUseCategory = beneficialUsesCV.Name; aggregateAmount.OrganizationUUID = organization.OrganizationUuid; aggregateAmount.VariableSpecificUUID = variable.VariableSpecificUuid; aggregateAmount.WaterSourceUUID = waterSource.WaterSourceUuid; aggregateAmount.MethodUUID = method.MethodUuid; aggregateAmount.DataPublicationDate = dataPublicationDate.Date; } var sut = CreateWaterAllocationAccessor(); var result = await sut.LoadAggregatedAmounts((new Faker()).Random.AlphaNumeric(10), new[] { aggregateAmount }); result.Should().BeTrue(); using (var db = new WaDEContext(Configuration.GetConfiguration())) { var dbAggregateAmount = await db.AggregatedAmountsFact.SingleAsync(); dbAggregateAmount.Should().NotBeNull(); dbAggregateAmount.PrimaryUseCategoryCV.Should().BeNull(); var dbAggBridge = await db.AggBridgeBeneficialUsesFact.SingleAsync(); dbAggBridge.Should().NotBeNull(); dbAggBridge.AggBridgeId.Should().BeGreaterThan(0); dbAggBridge.AggregatedAmountId.Should().Be(dbAggregateAmount.AggregatedAmountId); dbAggBridge.BeneficialUseCV.Should().Be(beneficialUsesCV.Name); db.ImportErrors.Should().HaveCount(0); } }