コード例 #1
0
        public static string GenerateTransactionName(TransactionGenData data)
        {
            switch (data.TransactionFormatType)
            {
            case TransactionFormatType.CompanyName:
                return(data.CompanyName);

            case TransactionFormatType.CompanyNameWithTransferNumber:
                return($"{data.CompanyName} {_faker.Finance.RoutingNumber()}");

            case TransactionFormatType.CardTypeCompanyName:
                return($"{_faker.PickRandom("CREDIT", "DEBIT", "TRANSFER")} {data.CompanyName}");

            case TransactionFormatType.CardTypeCompanyNameWithTransferNumber:
                return($"{_faker.PickRandom("CREDIT", "DEBIT", "TRANSFER")} {data.CompanyName} {_faker.Finance.RoutingNumber()}");

            case TransactionFormatType.PayPal:
                return($"PAYPAL *{data.CompanyName} {_faker.Finance.RoutingNumber()}");

            case TransactionFormatType.Payment:
                return($"Payment to {data.CompanyName} Ref {_faker.Finance.RoutingNumber()}");

            case TransactionFormatType.PosAuthorization:
            default:
                return($"{data.CompanyName} Ca Pos Authorisation");
            }
        }
コード例 #2
0
        public static List <TransactionGenData> GenerateInitialData(int number, double chanceOfContradiction)
        {
            Dictionary <string, int> addedCompanies = new Dictionary <string, int>();

            List <TransactionGenData> list = new List <TransactionGenData>();

            for (int i = 0; i < number; ++i)
            {
                if (i > 0 && chanceOfContradiction > _random.NextDouble())
                {
                    var randomTransaction = _faker.PickRandom(list);

                    TransactionGenData conflictingData = new TransactionGenData
                    {
                        CompanyName           = randomTransaction.CompanyName,
                        Category              = _faker.Commerce.Categories(1).FirstOrDefault(),
                        TransactionFormatType = randomTransaction.TransactionFormatType,
                    };

                    list.Add(conflictingData);
                    continue;
                }

                string company = _faker.Company.CompanyName("{{name.lastName}}");
                if (addedCompanies.ContainsKey(company))
                {
                    company = _faker.Company.CompanyName("{{name.lastName}}");

                    if (addedCompanies.ContainsKey(company))
                    {
                        // In case it's still not unique
                        company = Guid.NewGuid().ToString();
                    }
                }

                TransactionGenData data = new TransactionGenData
                {
                    CompanyName           = company,
                    Category              = _faker.Commerce.Categories(1).FirstOrDefault(),
                    TransactionFormatType = _faker.PickRandom <TransactionFormatType>()
                };

                list.Add(data);
            }

            return(list);
        }