Пример #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 DeleteChar()
        {
            AlfaBet ab     = new AlfaBet();
            var     r      = new Random();
            string  myWord = "غبار";

            int    i      = r.Next(1, myWord.Trim().Length);
            string result = ab.DeleteChar(myWord, i);

            Debug.Print(result);


            Assert.Pass();
        }