public async Task GetSiteAllocationAmountsDigestAsync_OrganizationUuidFilter_WithSite() { var configuration = Configuration.GetConfiguration(); AllocationAmountsFact allocationAmountsFact; SitesDim site; using (var db = new WaDEContext(configuration)) { allocationAmountsFact = await AllocationAmountsFactBuilder.Load(db); allocationAmountsFact.AllocationAmountId.Should().NotBe(0); site = await SitesDimBuilder.Load(db); await AllocationBridgeSitesFactBuilder.Load(db, new AllocationBridgeSitesFactBuilderOptions { AllocationAmountsFact = allocationAmountsFact, SitesDim = site }); } var filters = new SiteAllocationAmountsDigestFilters { OrganizationUUID = allocationAmountsFact.Organization.OrganizationUuid }; var sut = CreateWaterAllocationAccessor(); var result = (await sut.GetSiteAllocationAmountsDigestAsync(filters, 0, int.MaxValue)).ToList(); result.Should().HaveCount(1); result.First().Sites.Should().HaveCount(1); result.First().Sites.First().SiteUUID.Should().Be(site.SiteUuid); }
public async Task LoadSiteSpecificAmounts_SimpleLoad_Power() { OrganizationsDim organization; SitesDim site; VariablesDim variable; WaterSourcesDim waterSource; MethodsDim method; SiteSpecificAmount siteSpecificAmount; BeneficialUsesCV beneficialUses; BeneficialUsesCV primaryUseCategory; ReportYearCv reportYear; DateDim publicationDate; PowerType powerType; using (var db = new WaDEContext(Configuration.GetConfiguration())) { organization = await OrganizationsDimBuilder.Load(db); site = await SitesDimBuilder.Load(db); variable = await VariablesDimBuilder.Load(db); waterSource = await WaterSourcesDimBuilder.Load(db); method = await MethodsDimBuilder.Load(db); beneficialUses = await BeneficalUsesBuilder.Load(db); primaryUseCategory = await BeneficalUsesBuilder.Load(db); reportYear = await ReportYearCvBuilder.Load(db); publicationDate = await DateDimBuilder.Load(db); powerType = await PowerTypeBuilder.Load(db); siteSpecificAmount = SiteSpecificAmountBuilder.Create(new SiteSpecificAmountBuilderOptions { RecordType = SiteSpecificRecordType.Power, Method = method, Organization = organization, DataPublicationDate = publicationDate, Site = site, Variable = variable, WaterSource = waterSource, BeneficialUse = beneficialUses, PrimaryUseCategory = primaryUseCategory, ReportYear = reportYear, PowerType = powerType }); } siteSpecificAmount.PowerGeneratedGWh.Should().NotBeNullOrEmpty("Required field"); siteSpecificAmount.PowerType.Should().NotBeNullOrEmpty("Required field"); var sut = CreateWaterAllocationAccessor(); var result = await sut.LoadSiteSpecificAmounts((new Faker()).Random.AlphaNumeric(10), new[] { siteSpecificAmount }); result.Should().BeTrue(); using (var db = new WaDEContext(Configuration.GetConfiguration())) { var dbSiteVariableAmount = await db.SiteVariableAmountsFact.SingleAsync(); dbSiteVariableAmount.OrganizationId.Should().Be(organization.OrganizationId); dbSiteVariableAmount.SiteId.Should().Be(site.SiteId); dbSiteVariableAmount.VariableSpecificId.Should().Be(variable.VariableSpecificId); dbSiteVariableAmount.WaterSourceId.Should().Be(waterSource.WaterSourceId); dbSiteVariableAmount.MethodId.Should().Be(method.MethodId); dbSiteVariableAmount.PrimaryUseCategoryCV.Should().Be(primaryUseCategory.Name); dbSiteVariableAmount.ReportYearCv.Should().Be(reportYear.Name); dbSiteVariableAmount.PowerGeneratedGwh.Should().Be(double.Parse(siteSpecificAmount.PowerGeneratedGWh)); dbSiteVariableAmount.PowerType.Should().Be(powerType.Name); db.ImportErrors.Should().HaveCount(0); } }