public void InsertAfterReverse_Simple() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.InsertAfter("/*a*/", "1"); fr.InsertAfter("/*a*/", "2"); fr.InsertAfter("/*a*/", "3", reverse: true); fr.InsertAfter("/*a*/", "4", reverse: true); Assert.AreEqual("/*a*/4312", fr.ToString()); }
public void Combination_OrderAdvanced() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.InsertAfter("/*a*/", "1"); fr.InsertAfter("/*a*/", "2"); fr.Replace("/*a*/", "/*a*/"); fr.InsertAfter("/*a*/", "3"); Assert.AreEqual("/*a*/312", fr.ToString()); }
public void InsertAfterReverse_ComplexAndOrder() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*//*b*/"); fr.InsertAfter("/*b*/", "1"); fr.InsertAfter("/*a*/", "2", true); fr.InsertAfter("/*b*/", "3"); fr.InsertAfter("/*a*/", "4", true); Assert.AreEqual("/*a*/42/*b*/13", fr.ToString()); }
public void InsertCode(string code, string tag, bool insertAfterTag) { CheckTag(code, tag); if (insertAfterTag) { _code.InsertAfter(tag, code, reverse: true); } else { _code.InsertBefore(tag, code); } }
public void Combination2() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.InsertAfter("/*a*/", "/*c*/"); fr.Replace("/*a*/", "/*b*/"); fr.InsertAfter("/*b*/", "/*d*/"); fr.Replace("/*a*/", "a"); fr.Replace("/*b*/", "b"); fr.Replace("/*c*/", "c"); fr.Replace("/*d*/", "d"); Assert.AreEqual("bdc", fr.ToString()); }
private static void FailUsingToken(string token) { ShouldFail(delegate { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.Contains(token); }, "Expected exception was not thrown while using token \"" + token + "\" in function Contains."); ShouldFail(delegate { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.Replace(token, "x"); }, "Expected exception was not thrown while using token \"" + token + "\" in function Replace."); ShouldFail(delegate { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.InsertBefore(token, "x"); }, "Expected exception was not thrown while using token \"" + token + "\" in function InsertBefore."); ShouldFail(delegate { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.InsertAfter(token, "x"); }, "Expected exception was not thrown while using token \"" + token + "\" in function InsertAfter."); }
public void InsertAfter_Simple() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.InsertAfter("/*a*/", "123"); Assert.AreEqual("/*a*/123", fr.ToString()); }
public void Combination_Order() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*//*b*/"); fr.InsertBefore("/*b*/", "1"); fr.InsertBefore("/*b*/", "2"); fr.InsertAfter("/*a*/", "3"); fr.InsertAfter("/*a*/", "4"); fr.InsertBefore("/*b*/", "5"); fr.InsertAfter("/*a*/", "6"); Assert.AreEqual("/*a*/346125/*b*/", fr.ToString()); fr.Replace("/*a*/", "7"); fr.Replace("/*b*/", "8"); Assert.AreEqual("73461258", fr.ToString()); }
public void ReturnValue() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); Assert.AreEqual(true, fr.InsertAfter("/*a*/", "1")); Assert.AreEqual(true, fr.InsertBefore("/*a*/", "2")); Assert.AreEqual(true, fr.Replace("/*a*/", "/*b*/")); Assert.AreEqual(false, fr.InsertAfter("/*a*/", "1")); Assert.AreEqual(false, fr.InsertBefore("/*a*/", "2")); Assert.AreEqual(false, fr.Replace("/*a*/", "/*c*/")); Assert.AreEqual("2/*b*/1", fr.ToString()); Assert.AreEqual(true, fr.Replace("/*b*/", "/*a*/")); Assert.AreEqual(false, fr.Replace("/*x*/", "x1")); Assert.AreEqual(false, fr.Replace("/*b*/", "x4")); Assert.AreEqual(false, fr.Replace("/*c*/", "x5")); Assert.AreEqual(true, fr.Replace("/*a*/", "x6")); Assert.AreEqual("2x61", fr.ToString()); }
public void Combination_TokenReuse() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*/"); fr.Replace("/*a*/", "/*a*/"); Assert.AreEqual("/*a*/", fr.ToString()); fr.InsertAfter("/*a*/", "/*a*/"); Assert.AreEqual("/*a*//*a*/", fr.ToString()); fr.InsertBefore("/*a*/", "/*a*/"); Assert.AreEqual("/*a*//*a*//*a*//*a*/", fr.ToString()); }
public void InsertAfter_ComplexAndOrder() { var fr = new FastReplacer("/*", "*/"); fr.Append("/*a*//*b*/"); fr.InsertAfter("/*b*/", "1"); fr.InsertAfter("/*a*/", "2"); fr.InsertAfter("/*b*/", "3"); fr.InsertAfter("/*a*/", "4"); Assert.AreEqual("/*a*/24/*b*/13", fr.ToString()); }