public void RandomPopulate()
 {
     MyStringA = RandomTextGenerator.GetRandom();
     MyStringB = RandomTextGenerator.GetRandom();
     MyStringC = RandomTextGenerator.GetRandom();
     MyStringD = RandomTextGenerator.GetRandom();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 9527);

            WriteInfoToConsole(localEndPoint);
            Mediator mediator = new Mediator();

            Program.socketSettingCollection[SocketServerSettingEnum.BackLog]        = 100;
            Program.socketSettingCollection[SocketServerSettingEnum.LocalEndPoint]  = localEndPoint;
            Program.socketSettingCollection[SocketServerSettingEnum.MaxConnections] = 30;
            Program.socketSettingCollection[SocketServerSettingEnum.MaxSimultaneousAcceptOperation] = 10;
            Program.socketSettingCollection[SocketServerSettingEnum.MaxProcessingOperationCount]    = 3000;
            Program.socketSettingCollection[SocketServerSettingEnum.OperationBufferSize]            = 25;
            SocketListener <DataHolder> socketListener = new SocketListener <DataHolder>(mediator, Program.socketSettingCollection, false);

            Program.NodeManager  = new NodeManager(socketListener);
            Program.JobMonitor   = new JobMonitor(socketListener, Program.NodeManager.ConnectedClientInfo);
            Program.QueueManager = new QueueManager(Program.JobMonitor, Program.NodeManager, socketListener);
            ((INotifyCollectionChanged)Program.JobMonitor.ReadOnlyManagedJobInfo).CollectionChanged += Program.JobMonitor_CollectionChanged;
            Program.NodeManager.ConnectedClientInfo.CollectionChanged += Program.ConnectedClientInfo_CollectionChanged;
            socketListener.inital();
            System.Threading.Thread.Sleep(3000);
            RandomTextGenerator randomTextGenerator = new RandomTextGenerator();

            Program.QueueManager.dispatchJob(new Core.Info.JobInfo()
            {
                JobFunctionKey = "123456",
                JobId          = Guid.NewGuid(),
                JobName        = $"測試用_{randomTextGenerator.generate(5)}",
                JobStatus      = Core.Enums.JobStatus.Pending
            });
            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int numErrors = 0;

            for (int i = 0; i < 1000; i++)
            {
                var password = RandomTextGenerator.GenerateRandomString(32);

                try
                {
                    var paymentCard = new PaymentCard();
                    paymentCard.SetTestPaymentCard();
                    string text = paymentCard.ToEncryptedString("8UfROeJudbbl", password);

                    var paymentCard2 = new PaymentCard();
                    paymentCard2.InitializeFromEncryptedString(text, "8UfROeJudbbl", password);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(password);
                    numErrors++;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gera um texto randômico para o captcha
        /// </summary>
        /// <returns></returns>
        public string GetRandomText()
        {
            RandomTextGenerator textGenerator = new RandomTextGenerator();

            textGenerator.Settings.Length = _settings.NumChars;
            return(textGenerator.Generate());
        }
Exemplo n.º 5
0
 public IEnumerable <IParam> Parameters()
 {
     for (int i = 0; i < count; i++)
     {
         var newVal = RandomTextGenerator.Generate(7);
         yield return(new DictParams(new BenchDictKeyValue(i, newVal)));
     }
 }
        public void GenerateLengthTest()
        {
            RandomTextGenerator gen = new RandomTextGenerator(20);
            string test             = gen.Generate();

            Trace.WriteLine(test);
            Assert.AreEqual(test.Length, gen.Settings.Length);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Random               random     = new Random();
            List <string>        sentText   = new List <string>();
            List <string>        sortedText = new List <string>();
            SortingServiceClient ssClient   = new SortingServiceClient();
            int  putDataAttemps             = 0;
            bool showResultTexts            = false;
            RandomTextGenerator rtg         = new RandomTextGenerator(10, 60, 20);

            try
            {
                SortingServiceClient serviceClient = new SortingServiceClient();

                Guid transactionGuid = ssClient.BeginStream();
                Console.WriteLine("Streaming began for session ID:\n" + transactionGuid + "\nPlease wait ...\n");
                while (/*Console.ReadKey().Key != ConsoleKey.Escape &&*/ putDataAttemps++ < MAX_STREAM_ATTEMPTS)
                {
                    Console.WriteLine("sentText.Count " + sentText.Count);
                    List <string> rndList = new List <string>();
                    rndList.AddRange(rtg.GetRandomStringList());


                    sentText.AddRange(rndList);
                    ssClient.PutStreamData(transactionGuid, rndList.ToArray());
                }
                Console.WriteLine("Streaming ended.");
                CollectSortedText(serviceClient, transactionGuid, sortedText);

                sentText.Sort((x, y) => String.CompareOrdinal(x, y));
                bool isEqual = sentText.SequenceEqual(sortedText);
                if (showResultTexts)
                {
                    Console.WriteLine("sentText \n");
                    foreach (string line in sentText)
                    {
                        Console.WriteLine(line);
                    }
                    Console.WriteLine("sortedText \n");
                    foreach (string line in sortedText)
                    {
                        Console.WriteLine(line);
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("Service operation test: " + (isEqual?"Passed":"Failed"));
            }
            catch (Exception ex)
            {
                Console.WriteLine("\nException occured. The message is : " + ex.Message);
            }

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to exit application.");
            Console.ReadLine();
        }
Exemplo n.º 8
0
        private string GenerateRandomText(int length)
        {
            RandomTextGenerator.RandomTextGeneratorSettings Settings =
                new RandomTextGenerator.RandomTextGeneratorSettings {
                Length = length
            };
            RandomTextGenerator rtGenerator = new RandomTextGenerator(Settings);

            return(rtGenerator.Generate());
        }
    public void RandomPopulate()
    {
        BitsName = RandomTextGenerator.GetRandom();

        SomeBits = new string[Random.Range(1, 32)];

        for (int i = 0; i < SomeBits.Length; i++)
        {
            SomeBits[i] = RandomTextGenerator.GetRandom();
        }
    }
Exemplo n.º 10
0
 public void StartWork()
 {
     while (!stopFlag)
     {
         System.Threading.Thread.Sleep(rnd.Next(sleepTimeFrom, sleepTimeTo));
         var generatedString = RandomTextGenerator.GetRandomString(rnd.Next());
         OnDataGeneration(new GeneratedData {
             ThreadID = Thread.CurrentThread.Name, Data = generatedString, Time = DateTime.Now
         });
     }
 }
Exemplo n.º 11
0
    public void RandomPopulate()
    {
        PieceName = RandomTextGenerator.GetRandom();

        SomePieces = new int[Random.Range(1, 32)];

        for (int i = 0; i < SomePieces.Length; i++)
        {
            SomePieces[i] = Random.Range(0, int.MaxValue);
        }
    }
Exemplo n.º 12
0
        public void Generate_Text_With_Correct_Size(long filesize)
        {
            var rowGenerator      = new RowGenerator();
            var filesizeGenerator = new RandomTextGenerator(filesize, rowGenerator);
            var sb = new StringBuilder();

            foreach (var row in filesizeGenerator)
            {
                sb.Append(row);
            }

            Assert.AreEqual(filesize, Encoding.Default.GetByteCount(sb.ToString()));
        }
        public void GenerateLargeTest()
        {
            RandomTextGenerator.RandomTextGeneratorSettings gensettings =
                new RandomTextGenerator.RandomTextGeneratorSettings
            {
                Length       = 1000,
                AllowedChars = "ABCDEFGEHIJKLNMOPQRSTUVXYZ012345789"
            };
            RandomTextGenerator gen = new RandomTextGenerator();
            string test             = gen.Generate();

            Trace.WriteLine(test);
            Assert.AreEqual(test.Length, gen.Settings.Length);
        }
Exemplo n.º 14
0
        public void Test_RandomGenerator()
        {
            string result1 = RandomTextGenerator.GetRandomString(1);
            string result2 = RandomTextGenerator.GetRandomString(2);
            string result3 = RandomTextGenerator.GetRandomString(3);

            Assert.IsTrue(result1.Length >= 5 && result1.Length <= 10);
            Assert.IsTrue(result2.Length >= 5 && result2.Length <= 10);
            Assert.IsTrue(result3.Length >= 5 && result3.Length <= 10);

            Assert.AreNotEqual(result1, result2);
            Assert.AreNotEqual(result2, result3);
            Assert.AreNotEqual(result1, result3);
        }
Exemplo n.º 15
0
        public TwoChatsHandler(ChatSpammerSettings spammerSettings, IChatHandler chat1, IChatHandler chat2)
        {
            Settings         = spammerSettings;
            UniqueIdentifier = RandomTextGenerator.Generate(4);
            string dateStr = string.Format("{0:dd.MM.yy_HH.mm.ss}", DateTime.Now);

            UsedFolder = ResourcesAndConsts.Instance().FolderForСorrespondenceAndLogs + "/" + dateStr + "__" + UniqueIdentifier;
            Directory.CreateDirectory(UsedFolder);
            Chat1 = chat1;
            Chat2 = chat2;
            if (spammerSettings.BotScenario != null)
            {
                BotScenario = spammerSettings.BotScenario.Clone() as IBotScenario;
            }
        }
Exemplo n.º 16
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            SetMessage(SourceFile);

            var generator = new RandomTextGenerator
            {
                SourcePath = SourceFile,
                OutputPath = $"c:/logs/output_{DateTime.Now.Minute}.txt",
                ReplaceCarriageNewLines = ReplaceBreaksWithLine ? Environment.NewLine : string.Empty
            };

            generator.Parse(TextLength);

            SetMessage(generator.OutputMessage);

            SetMessage(generator.Print(500));
        }
Exemplo n.º 17
0
    public void RandomPopulate()
    {
        MyBits   = new Bits();
        MyPieces = new Pieces();
        MyBits.RandomPopulate();
        MyPieces.RandomPopulate();

        StuffName = RandomTextGenerator.GetRandom();
        DescA     = RandomTextGenerator.GetRandom();
        DescB     = RandomTextGenerator.GetRandom();
        DescC     = RandomTextGenerator.GetRandom();
        DescD     = RandomTextGenerator.GetRandom();
        DescE     = RandomTextGenerator.GetRandom();

        AttrA = Random.Range(0, int.MaxValue);
        AttrB = Random.Range(0, int.MaxValue);
        AttrC = Random.Range(0, int.MaxValue);
    }
Exemplo n.º 18
0
    public void RandomPopulate()
    {
        JunkName = RandomTextGenerator.GetRandom();
        JunkData = RandomTextGenerator.GetRandom();

        FloatA = Random.Range(0f, float.MaxValue);
        FloatB = Random.Range(0f, float.MaxValue);
        FloatC = Random.Range(0f, float.MaxValue);
        FloatD = Random.Range(0f, float.MaxValue);

        IntA = Random.Range(0, int.MaxValue);
        IntB = Random.Range(0, int.MaxValue);

        MyStuff = new Stuff();
        MyThing = new Thing();

        MyStuff.RandomPopulate();
        MyThing.RandomPopulate();
    }
Exemplo n.º 19
0
        private static void RunRandomTextGenerator()
        {
            Console.WriteLine($"{Ansi.MAGENTA}RANDOM TEXT GENERATOR!{Ansi.GRAY_0}");
            Console.WriteLine($"{Ansi.MAGENTA}----------------------{Ansi.GRAY_0}");
            Console.WriteLine($"{Ansi.MAGENTA}-------type G to gen--{Ansi.GRAY_0}");
            Console.WriteLine($"{Ansi.MAGENTA}-------type C to con--{Ansi.GRAY_0}");

            var exitKey = Console.ReadLine();

            while (exitKey == "G")
            {
                GenerateText();
                exitKey = Console.ReadLine();
            }

            if (exitKey == "C")
            {
                if (AskForPath("source", out var path) && AskForPath("output", out var outputPath))
                {
                    // GenerateText()
                    try
                    {
                        var generator = new RandomTextGenerator {
                            SourcePath = path, OutputPath = outputPath
                        };
                        generator.Parse(30000);

                        Console.WriteLine($"{Ansi.MAGENTA}{generator.OutputMessage}{Ansi.GRAY_0}");
                        // Console.WriteLine($"{Ansi.GREEN_BACK}{generator.View()}{Ansi.GRAY_0}");
                        Console.WriteLine($"{Ansi.GREEN_BACK}{generator.Print(500)}{Ansi.GRAY_0}");
                        Console.WriteLine($"{Ansi.RED_1}Press any key to exit.{Ansi.GRAY_0}");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Console.WriteLine("Error, Press key to exit.");
                    }
                    var exitKeys = Console.ReadLine();
                }
            }
        }
Exemplo n.º 20
0
        private static void GenerateText()
        {
            try
            {
                // var generator = new RandomTextGenerator {SourcePath = path, OutputPath = outputPath };
                var generator = new RandomTextGenerator {
                    SourcePath = "c:/logs/radiohead_lyrics_07-20-19.txt", OutputPath = $"c:/logs/output_{DateTime.Now.Minute}.txt"
                };
                generator.Parse(int.MaxValue);

                Console.WriteLine($"{Ansi.MAGENTA}{generator.OutputMessage}{Ansi.GRAY_0}");
                // Console.WriteLine($"{Ansi.BRIGHT_GREEN}{generator.ViewChar()}{Ansi.GRAY_0}");
                Console.WriteLine($"{Ansi.GREEN_BACK}{generator.Print(900)}{Ansi.GRAY_0}");
                Console.WriteLine($"{Ansi.RED_1}Press any key to exit.{Ansi.GRAY_0}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Error, Press key to exit.");
            }
        }
Exemplo n.º 21
0
    public void Congradulate()
    {
        RandomTextGenerator rtg = new RandomTextGenerator();
        string message          = rtg.GetRandomStatement();
        int    temp             = Random.Range(0, 3);

        /*
         * switch (temp)
         * {
         *  default:
         *      text1.text = message;
         *      text1.gameObject.GetComponent<Animator>().Play("Text",0,0);
         *      break;
         *  case 1:
         *      text2.text = message;
         *      text2.gameObject.GetComponent<Animator>().Play("Text", 0, 0);
         *      break;
         *  case 2:
         *      text3.text = message;
         *      text3.gameObject.GetComponent<Animator>().Play("Text", 0, 0);
         *      break;
         * }
         */
    }
Exemplo n.º 22
0
        public string GetFreeDir()
        {
            Block();
            string res = null;

            foreach (var item in dirNameAndStatus)
            {
                if (item.Value)
                {
                    dirNameAndStatus[item.Key] = false;
                    res = Path.Combine(CacheFolderGlobal, item.Key);
                    break;
                }
            }
            if (res == null)
            {
                string dirName = RandomTextGenerator.Generate(7);
                res = Path.Combine(CacheFolderGlobal, dirName);
                Directory.CreateDirectory(res);
                dirNameAndStatus.Add(dirName, false);
            }
            Unblock();
            return(res);
        }
Exemplo n.º 23
0
        static void TestIDict(int count)
        {
            Console.WriteLine("{");
            Dictionary <string, object> idict = new Dictionary <string, object>(count);

            Stopwatch sw  = new Stopwatch();
            Stopwatch sw2 = new Stopwatch();

            sw.Start();
            List <string> keys     = new List <string>();
            int           magicNum = count / 4;

            for (int i = 0; i < count; i++)
            {
                string newKey = RandomTextGenerator.Generate(20);
                object val    = i.ToString();
                sw2.Start();
                idict.Add(newKey, val);
                sw2.Stop();
                if (i % magicNum == 0)
                {
                    keys.Add(newKey);
                }
            }
            Console.WriteLine($"\tFill time - {count} records: {sw.ElapsedMilliseconds} ms.");
            Console.WriteLine($"\tFill time - {count} records ('Add' calls only): {sw2.ElapsedMilliseconds} ms.");
            sw2.Stop();
            long kbytes = 0;

            if (count > 2000000)
            {
                kbytes = GC.GetTotalMemory(true) / (1024 * 1024);
            }
            else
            {
                kbytes = GetObjSize(idict) / (1024 * 1024);
            }

            Console.WriteLine($"\tSize: {kbytes} MBs.");

            object bufVal;

            foreach (var key in keys)
            {
                int nanoseconds;
                Console.WriteLine("\t" + key + "{");
                sw.Restart();
                bufVal = idict.ContainsKey(key);
                sw.Stop();
                nanoseconds = (int)(sw.ElapsedTicks * 1000000000 / Stopwatch.Frequency);
                Console.WriteLine($"\t\tContains key operation: {nanoseconds} ns.");

                sw.Restart();
                bufVal = idict[key];
                sw.Stop();
                nanoseconds = (int)(sw.ElapsedTicks * 1000000000 / Stopwatch.Frequency);
                Console.WriteLine($"\t\tGet value operation: {nanoseconds} ns.");
                Console.WriteLine($"\t\tValue: {bufVal}");


                sw.Restart();
                bufVal = idict.First(kv => kv.Value == bufVal).Value;
                sw.Stop();
                nanoseconds = (int)(sw.ElapsedTicks * 1000000000 / Stopwatch.Frequency);
                Console.WriteLine($"\t\tFind by value with LINQ: {nanoseconds} ns.");

                sw.Restart();
                foreach (var kv in idict)
                {
                    if (kv.Value == bufVal)
                    {
                        bufVal = kv.Value;
                        break;
                    }
                }
                sw.Stop();
                nanoseconds = (int)(sw.ElapsedTicks * 1000000000 / Stopwatch.Frequency);
                Console.WriteLine($"\t\tFind by value with cycle: {nanoseconds} ns.");


                Console.WriteLine("\t}");
            }

            sw.Restart();
            bufVal = idict.OrderBy(k => k.Key);
            Console.WriteLine($"\tOrder operation: {sw.ElapsedMilliseconds} ms.");

            Console.WriteLine("}\n");
        }