public void testFindNext()
 {
     StringTheory theory = new StringTheory("Mares eat oats Mares eat oats");
     Assert.True(theory.FindNext("eat") == 6, "1) Couldn't find the test string");
     Assert.True(theory.FindNext("eat") == 0x15, "2) Couldn't find the test string");
     theory.Reset();
     Assert.True(theory.FindNext("eat") == 6, "3) Couldn't find the test string");
 }
 public void testSerialization()
 {
     string str = "Mares eat oats Mares eat oats";
     StringTheory graph = new StringTheory("Mares eat oats Mares eat oats");
     graph.RevFindNext("eat");
     Assert.True(graph.RevFindNext("eat") == 6, "");
     string path = "st_test.per";
     bool condition = true;
     Stream serializationStream = null;
     try
     {
         serializationStream = File.Open(path, FileMode.Create, FileAccess.ReadWrite);
         new BinaryFormatter().Serialize(serializationStream, graph);
         serializationStream.Close();
     }
     catch (IOException exception)
     {
         Console.WriteLine(exception.StackTrace);
         condition = false;
     }
     Assert.True(condition, "Something went wrong while persisting the string to a file.");
     graph = null;
     condition = true;
     try
     {
         serializationStream = File.Open(path, FileMode.Open, FileAccess.Read);
         BinaryFormatter formatter2 = new BinaryFormatter();
         graph = (StringTheory)formatter2.Deserialize(serializationStream);
     }
     catch (IOException exception2)
     {
         Console.WriteLine(exception2.StackTrace);
         condition = false;
     }
     Assert.True(condition, "Something went wrong while retrieving the string from a file.");
     Assert.True(str.Equals(graph.ToString()), "Strings don't match now.");
     Assert.True(graph.FindNext("eat") == 0x15, "string state is incorrect!");
 }