コード例 #1
0
        public static AllocationAmountsFact Create(AllocationAmountsFactBuilderOptions opts)
        {
            var faker = new Faker <AllocationAmountsFact>()
                        .RuleFor(a => a.OrganizationId, f => opts.OrganizationsDim?.OrganizationId ?? OrganizationsDimBuilder.GenerateId())
                        .RuleFor(a => a.VariableSpecificId, f => opts.VariablesDim?.VariableSpecificId ?? VariablesDimBuilder.GenerateId())
                        .RuleFor(a => a.WaterSourceId, f => opts.WaterSourcesDim?.WaterSourceId ?? WaterSourcesDimBuilder.GenerateId())
                        .RuleFor(a => a.MethodId, f => opts.MethodsDim?.MethodId ?? MethodsDimBuilder.GenerateId())
                        .RuleFor(a => a.PrimaryUseCategoryCV, f => opts.PrimaryBeneficialUsesCv?.Name)
                        .RuleFor(a => a.DataPublicationDateId, f => opts.DataPublicationDate?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.DataPublicationDoi, f => f.Random.Words(3))
                        .RuleFor(a => a.AllocationNativeId, f => f.Random.Uuid().ToString())
                        .RuleFor(a => a.DataPublicationDoi, f => f.Random.Word())
                        .RuleFor(a => a.AllocationApplicationDateID, f => opts.AllocationApplicationDate?.DateId)
                        .RuleFor(a => a.AllocationPriorityDateID, f => opts.AllocationPriorityDate?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.AllocationExpirationDateID, f => opts.AllocationExpirationDate?.DateId)
                        .RuleFor(a => a.AllocationOwner, f => f.Name.FullName())
                        .RuleFor(a => a.AllocationBasisCv, f => opts.WaterAllocationBasis?.Name)
                        .RuleFor(a => a.AllocationLegalStatusCv, f => opts.LegalStatus?.Name)
                        .RuleFor(a => a.AllocationTypeCv, f => opts.WaterAllocationType?.Name)
                        .RuleFor(a => a.AllocationTimeframeEnd, f => opts.AllocationTimeframeStartDate?.Date.ToString("mm/dd"))
                        .RuleFor(a => a.AllocationTimeframeEnd, f => opts.AllocationTimeframeEndDate?.Date.ToString("mm/dd"))
                        .RuleFor(a => a.AllocationAmount, f => f.Random.Double(0, 1000))
                        .RuleFor(a => a.AllocationMaximum, f => f.Random.Double(0, 1000))
            ;

            switch (opts.RecordType ?? (new Faker()).PickRandom <WaterAllocationRecordType>())
            {
            case WaterAllocationRecordType.Ag:
                faker.RuleFor(a => a.IrrigatedAcreage, f => f.Random.Double(0, 10000))
                .RuleFor(a => a.CropTypeCV, f => opts.CropType?.Name)
                .RuleFor(a => a.IrrigationMethodCV, f => opts.IrrigationMethod?.Name)
                .RuleFor(a => a.AllocationCropDutyAmount, f => f.Random.Double(0, 1000));
                break;

            case WaterAllocationRecordType.Power:
                faker.RuleFor(a => a.GeneratedPowerCapacityMW, f => f.Random.Double(0, 10000));
                break;

            case WaterAllocationRecordType.Civilian:
                faker.RuleFor(a => a.PopulationServed, f => f.Random.Long(0, 10000000))
                .RuleFor(a => a.CommunityWaterSupplySystem, f => f.Address.City())
                .RuleFor(a => a.CustomerTypeCV, f => opts.CustomerType?.Name)
                .RuleFor(a => a.SdwisidentifierCV, f => opts.SDWISIdentifier?.Name);
                break;
            }

            return(faker);
        }
コード例 #2
0
        public static SiteVariableAmountsFact Create(SiteVariableAmountsFactBuilderOptions opts)
        {
            var faker = new Faker <SiteVariableAmountsFact>()
                        .RuleFor(a => a.OrganizationId, f => opts.OrganizationsDim?.OrganizationId ?? OrganizationsDimBuilder.GenerateId())
                        .RuleFor(a => a.SiteId, f => opts.SiteDim?.SiteId ?? SitesDimBuilder.GenerateId())
                        .RuleFor(a => a.VariableSpecificId, f => opts.VariablesDim?.VariableSpecificId ?? VariablesDimBuilder.GenerateId())
                        .RuleFor(a => a.WaterSourceId, f => opts.WaterSourcesDim?.WaterSourceId ?? WaterSourcesDimBuilder.GenerateId())
                        .RuleFor(a => a.MethodId, f => opts.MethodsDim?.MethodId ?? MethodsDimBuilder.GenerateId())
                        .RuleFor(a => a.TimeframeStartID, f => opts.TimeframeStart?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.TimeframeEndID, f => opts.TimeframeEnd?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.DataPublicationDateID, f => opts.DataPublicationDate?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.DataPublicationDoi, f => f.Random.Words(3))
                        .RuleFor(a => a.ReportYearCv, f => opts.ReportYearCv?.Name)
                        .RuleFor(a => a.Amount, f => opts.Amount ?? f.Random.Double(1, 10000))
                        .RuleFor(a => a.PrimaryUseCategoryCV, f => opts.PrimaryBeneficialUsesCv?.Name)
            ;

            switch (opts.RecordType ?? (new Faker()).PickRandom <SiteVariableAmountsRecordType>())
            {
            case SiteVariableAmountsRecordType.Ag:
                faker.RuleFor(a => a.IrrigatedAcreage, f => f.Random.Double(0, 10000))
                .RuleFor(a => a.CropTypeCv, f => opts.CropType?.Name)
                .RuleFor(a => a.IrrigationMethodCv, f => opts.IrrigationMethod?.Name)
                .RuleFor(a => a.AllocationCropDutyAmount, f => f.Random.Double(0, 1000));
                break;

            case SiteVariableAmountsRecordType.Power:
                faker.RuleFor(a => a.PowerGeneratedGwh, f => f.Random.Double(0, 10000));
                break;

            case SiteVariableAmountsRecordType.Civilian:
                faker.RuleFor(a => a.PopulationServed, f => f.Random.Long(0, 10000000))
                .RuleFor(a => a.CommunityWaterSupplySystem, f => f.Address.City())
                .RuleFor(a => a.CustomerTypeCv, f => opts.CustomerType?.Name)
                .RuleFor(a => a.SDWISIdentifierCv, f => opts.SDWISIdentifier?.Name);
                break;
            }

            return(faker);
        }