示例#1
0
        private void MakeFailFile()
        {
            //read word file.
            // run each algoritem
            //save  word . new_word
            string  myWord;
            AlfaBet ab = new AlfaBet();
            var     r  = new Random();
            string  result;
            int     i = 0;

            var f = File.ReadAllLines(Environment.CurrentDirectory + @"\..\..\File\correct_word.txt");

            foreach (var l in f)
            {
                if (l.Length > 2)
                {
                    myWord = l.ToString();
                    string mychar = ab.GetRandomFarsiChar(1);
                    //string myWord = "تستی";
                    char[] array = myWord.ToCharArray();
                    i      = r.Next(1, myWord.Trim().Length);
                    result = myWord.Substring(0, i) + mychar + myWord.Substring(i);
                    File.AppendAllText(Environment.CurrentDirectory + @"\..\..\File\All_word.txt",
                                       l + @"," + result + Environment.NewLine);



                    i      = r.Next(1, myWord.Trim().Length);
                    result = ab.SwapChars(myWord, i - 1);
                    File.AppendAllText(Environment.CurrentDirectory + @"\..\..\File\All_word.txt",
                                       l + @"," + result + Environment.NewLine);



                    i      = r.Next(1, myWord.Trim().Length);
                    result = ab.DeleteChar(myWord, i);
                    File.AppendAllText(Environment.CurrentDirectory + @"\..\..\File\All_word.txt",
                                       l + @"," + result + Environment.NewLine);



                    i      = r.Next(1, myWord.Trim().Length);
                    result = ab.RepeatChars(myWord, i);
                    File.AppendAllText(Environment.CurrentDirectory + @"\..\..\File\All_word.txt",
                                       l + @"," + result + Environment.NewLine);
                }
            }

            Assert.Pass();
        }
示例#2
0
        public void AppendRandomChar()
        {
            AlfaBet ab     = new AlfaBet();
            string  myWord = "غبار";
            string  s      = ab.GetRandomFarsiChar(1);

            Debug.Print(s);

            //append random char/string in text
            var r = new Random();
            int i = r.Next(1, myWord.Trim().Length);

            char[] array = myWord.ToCharArray();

            string result = myWord.Substring(0, i) + s + myWord.Substring(i);

            Debug.Print(result);

            Assert.Pass();
        }