示例#1
0
        private static IEnumerable <Kontonummer> CreateKontonummerWithGenerator(int amountToCreate, string registerNummer = null, string kontogruppeNummer = null)
        {
            var returnedNumbers = 0;

            while (returnedNumbers < amountToCreate)
            {
                Kontonummer kontoNr;
                try
                {
                    var generatedKontonummer = KontonummerDigitGenerator.GenerateKontonummer(registerNummer, kontogruppeNummer);
                    kontoNr = KontonummerValidator.GetAndForceValidKontonummer(generatedKontonummer);
                }
                catch (ArgumentException)
                {
                    continue; // this number has no valid checksum
                }

                ++returnedNumbers;
                yield return(kontoNr);
            }
        }
示例#2
0
        private static List <Kontonummer> GetKontonummerListUsingGenerator(KontonummerDigitGenerator generator, int length)
        {
            var result         = new List <Kontonummer>();
            int numAddedToList = 0;

            while (numAddedToList < length)
            {
                Kontonummer kontoNr;
                try
                {
                    kontoNr = KontonummerValidator.GetAndForceValidKontonummer(generator.GenerateKontonummer());
                }
                catch (ArgumentException)
                {
                    // this number has no valid checksum
                    continue;
                }
                result.Add(kontoNr);
                numAddedToList++;
            }
            return(result);
        }
示例#3
0
        /**
         * Returns a List with random but syntactically valid Kontonummer instances
         * for a given Registernummer.
         *
         * @param registernummer
         *            A String representing the Registernummer to use for all
         *            Kontonummer instances
         * @param length
         *            Specifies the number of Kontonummer instances to create in the
         *            returned List
         * @return A List with Kontonummer instances
         */
        public static List <Kontonummer> GetKontonummerListForRegisternummer(string registernummer, int length)
        {
            KontonummerValidator.ValidateRegisternummerSyntax(registernummer);

            return(GetKontonummerListUsingGenerator(new RegisternummerKontonrDigitGenerator(registernummer), length));
        }
示例#4
0
        /**
         * Returns a List with random but syntactically valid Kontonummer instances
         * for a given AccountType.
         *
         * @param accountType
         *            A String representing the AccountType to use for all
         *            Kontonummer instances
         * @param length
         *            Specifies the number of Kontonummer instances to create in the
         *            returned List
         * @return A List with Kontonummer instances
         */
        public static List <Kontonummer> GetKontonummerListForAccountType(string accountType, int length)
        {
            KontonummerValidator.ValidateAccountTypeSyntax(accountType);

            return(GetKontonummerListUsingGenerator(new AccountTypeKontonrDigitGenerator(accountType), length));
        }
示例#5
0
 /// <param name="registerNummer">A String representing the Registernummer to use for all Kontonummer instances</param>
 /// <param name="length">Specifies the number of Kontonummer instances to create in the returned List</param>
 /// <returns>A list with random, but syntactically valid, Kontonummer instances for a given registernummer.</returns>
 public static IEnumerable <Kontonummer> GetKontonummerListForRegisternummer(string registerNummer, int length)
 {
     KontonummerValidator.ValidateRegisternummerSyntax(registerNummer);
     return(CreateKontonummerWithGenerator(length, registerNummer: registerNummer));
 }
示例#6
0
 /// <param name="kontogruppeNummer">A String representing the AccountType to use for all Kontonummer instances</param>
 /// <param name="length">Specifies the number of Kontonummer instances to create in the returned List</param>
 /// <returns>A list with random, but syntactically valid, Kontonummer instances for a given kontogruppe.</returns>
 public static IEnumerable <Kontonummer> GetKontonummerListForAccountType(string kontogruppeNummer, int length)
 {
     KontonummerValidator.ValidateAccountTypeSyntax(kontogruppeNummer);
     return(CreateKontonummerWithGenerator(length, kontogruppeNummer: kontogruppeNummer));
 }