private static string GeneratePostfix(WordBankModel words, int max)
 {
     if (Settings.RandomPostfix)
     {
         int postLength = RandomNumber(3, max);
         return(words[postLength][RandomNumber(0, words[postLength].Count - 1)] + "");
     }
     else
     {
         return(Settings.UsernamePostfix);
     }
 }
            private static string GenerateMiddle(WordBankModel words)
            {
                if (Settings.RandomUsername)
                {
                    int middleLength = RandomNumber(3, 6);

                    return(words[middleLength][RandomNumber(0, words[middleLength].Count - 1)] + "");
                }
                else
                {
                    return(Settings.Username);
                }
            }
Exemple #3
0
        public async Task <bool> CreateAccounts(int accountCount)
        {
            await Task.Run(() =>
            {
                using (WordBankModel words = new WordBankModel())
                {
                    for (var i = 0; i < accountCount; i++)
                    {
                        Model account = new Model(words);
                        OnEventAccountAdded(account);
                        ConcurrentQueue.Enqueue(account);
                    }
                }
            });

            _queueNotifier.Set();
            return(true);
        }
            public static string GenerateCombinedUsername(WordBankModel words)
            {
                string middle = GenerateMiddle(words);
                int    max    = 15 - middle.Length;

                ;

                if (Settings.RandomPostfix && Settings.RandomPrefix)
                {
                    max /= 2;
                }


                if (max > 6)
                {
                    max = 6;
                }

                string prefix  = "";
                string postfix = "";

                if (max == 1 || max == 2)
                {
                    prefix  = RandomString(max);
                    postfix = RandomString(max);
                }
                else if (max > 2)
                {
                    prefix  = GeneratePrefix(words, max);
                    postfix = GeneratePostfix(words, max);
                }


                string username = FirstLetterToUpper(prefix) + FirstLetterToUpper(middle) + FirstLetterToUpper(postfix);

                if (username.Length > 15)
                {
                    username = username.Substring(0, 15);
                }

                return(username);
            }
 public Model(WordBankModel words) : base(Generator.GenerateCombinedUsername(words), Generator.GeneratePassword(), Generator.GenerateCountry(), Generator.GenerateDateOfBirth())
 {
     AccountModel.PendingCount++;
     this.TypeOfTask = TaskType.Create;
     //Status = StatusType.Pending;
 }