コード例 #1
0
        public void TestRandomAmericanAddress()
        {
            var testResult = PostalAddress.RandomAmericanAddress();

            Assert.IsNotNull(testResult);
            Assert.IsNotNull(testResult.Street);
            Assert.IsNotNull(testResult.CityArea);
            Console.WriteLine(testResult);
        }
コード例 #2
0
        public void TestToData()
        {
            var testSubject = PostalAddress.RandomAmericanAddress();
            var testResult  = testSubject.ToData(KindsOfTextCase.Kabab);

            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(0, testResult.Count);
            foreach (var tr in testResult.Keys)
            {
                Console.WriteLine($"{tr}, {testResult[tr]}");
            }
        }
コード例 #3
0
ファイル: AmericanAssets.cs プロジェクト: nofuture-git/31g
        protected internal override NamedTradeline GetNamedReceivableForItemAndGroup(string item, string grp,
                                                                                     AmericanDomusOpesOptions options, double rate)
        {
            const StringComparison OPT      = StringComparison.OrdinalIgnoreCase;
            const float            FED_RATE = RiskFreeInterestRate.DF_VALUE;

            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            var startDate = options.Inception;
            var amtR      = options.SumTotal;

            var isCheckingAccount = string.Equals(grp, AssetGroupNames.INSTITUTIONAL, OPT) &&
                                    string.Equals(item, INSTITUTIONAL_CHECKING, OPT);
            var isSavingsAccount = string.Equals(grp, AssetGroupNames.INSTITUTIONAL, OPT) &&
                                   string.Equals(item, INSTITUTIONAL_SAVINGS, OPT);
            var isMortgage = !options.IsRenting && string.Equals(grp, AssetGroupNames.REAL_PROPERTY, OPT) &&
                             string.Equals(item, REAL_PROPERTY_HOME_OWNERSHIP, OPT);
            var isCarLoan = options.NumberOfVehicles > 0 &&
                            string.Equals(grp, AssetGroupNames.PERSONAL_PROPERTY, OPT) &&
                            string.Equals(item, PERSONAL_PROPERTY_MOTOR_VEHICLES, OPT);

            NamedTradeline p;

            if (isCheckingAccount)
            {
                var checkingAmt = amtR == null || amtR == 0
                    ? _randCheckingAcctAmt
                    : _checkingAccountRate * amtR;
                p = DepositAccount.RandomCheckingAccount(options.PersonsName, startDate,
                                                         $"{Etx.RandomInteger(1, 9999):0000}");
                ((DepositAccount)p).Deposit(startDate.AddDays(-1), (checkingAmt ?? 0).ToPecuniam());
            }
            else if (isSavingsAccount)
            {
                var savingAmt = amtR == null || amtR == 0
                    ? _randSavingsAcctAmt
                    : _savingsAccountRate * amtR;
                p = DepositAccount.RandomSavingAccount(options.PersonsName, startDate);
                ((DepositAccount)p).Deposit(startDate.AddDays(-1), (savingAmt ?? 0).ToPecuniam());
            }
            else if (isMortgage || isCarLoan)
            {
                var homeDebtAmt = amtR == null || amtR == 0
                    ? _randHomeDebt
                    : _homeDebtRate * amtR;
                var homeEquityAmt = amtR == null || amtR == 0
                    ? _randHomeEquity
                    : _homeEquityRate * amtR;
                var carDebtAmt = amtR == null || amtR == 0
                    ? _randCarDebt
                    : _carDebtRate * amtR;
                var carEquityAmt = amtR == null || amtR == 0
                    ? _randCarEquity
                    : _carEquityRate * amtR;

                var baseRate    = isMortgage ? FED_RATE : FED_RATE + 3.2;
                var creditScore = new PersonalCreditScore(options.FactorOptions.DateOfBirth)
                {
                    OpennessZscore          = options.Personality?.Openness?.Value?.Zscore ?? 0D,
                    ConscientiousnessZscore = options.Personality?.Conscientiousness?.Value?.Zscore ?? 0D
                };
                var randRate = (float)creditScore.GetRandomInterestRate(null, baseRate) * 0.01f;

                var id = isMortgage
                    ? (Identifier)PostalAddress.RandomAmericanAddress()
                    : Vin.RandomVin();

                var remainingCost = isMortgage
                    ? (homeDebtAmt ?? 0).ToPecuniam()
                    : (carDebtAmt ?? 0).ToPecuniam();

                var totalValue = isMortgage
                    ? ((homeDebtAmt ?? 0) + (homeEquityAmt ?? 0)).ToPecuniam()
                    : ((carDebtAmt ?? 0) + (carEquityAmt ?? 0)).ToPecuniam();

                var buyer = options.Personality;

                var termInYears = isMortgage ? 30 : 5;

                Func <bool> irresp = () => false;
                if (buyer != null)
                {
                    irresp = buyer.GetRandomActsIrresponsible;
                }

                p = SecuredFixedRateLoan.RandomSecuredFixedRateLoanWithHistory(remainingCost,
                                                                               totalValue,
                                                                               randRate,
                                                                               termInYears,
                                                                               id, irresp);

                p.Name = item;
                p.AddName(KindsOfNames.Group, grp);
            }
            else
            {
                p = base.GetNamedReceivableForItemAndGroup(item, grp, options, rate);
            }

            return(p);
        }