/// <summary> /// Markov algorithm performs /// </summary> /// <returns></returns> public MyString DoingAlgorithm() { int i = 0; int countPerformedSubstitutions = 0; MyString resultLine = new MyString(line); while(i < substitutions.Count) { if(resultLine.Find(substitutions[i].Key) != -1) { resultLine = resultLine.Replace(substitutions[i].Key, substitutions[i].Value); i = 0; if (countPerformedSubstitutions < N) { countPerformedSubstitutions++; } else { throw new InvalidOperationException("Substitutions performed too long."); } } else { i++; } } return resultLine; }
public void TestMethodFind2() { MyString a = new MyString(); MyString b = new MyString(); a.GetLine("inA.txt"); b.GetLine("inB.txt"); Assert.AreEqual(a.Find(b), -1); }