|
|
|
@@ -38,7 +38,7 @@ namespace UnitTests |
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void PatternReplacement()
|
|
|
|
public void Test_Pattern_Replacement()
|
|
|
|
{
|
|
|
|
Dictionary<string, string> testPatterns = new Dictionary<string, string>()
|
|
|
|
{
|
|
|
|
@@ -48,12 +48,28 @@ namespace UnitTests |
|
|
|
|
|
|
|
using (DocX replaceDoc = DocX.Load(directory_documents + "ReplaceTests.docx"))
|
|
|
|
{
|
|
|
|
// Make sure the origional string are the document.
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("<COURT NAME>").Count == 2);
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("<Case Number>").Count == 2);
|
|
|
|
|
|
|
|
// Make sure the new strings are not in the document.
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("Fred Frump").Count == 0);
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("cr-md-2011-1234567").Count == 0);
|
|
|
|
|
|
|
|
// Do the replacing
|
|
|
|
foreach (var p in testPatterns)
|
|
|
|
{
|
|
|
|
replaceDoc.ReplaceText("<" + p.Key + ">", p.Value, false, RegexOptions.IgnoreCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
replaceDoc.SaveAs(directory_documents + "ReplaceResults.docx");
|
|
|
|
// Make sure the origional string are no longer in the document.
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("<COURT NAME>").Count == 0);
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("<Case Number>").Count == 0);
|
|
|
|
|
|
|
|
// Make sure the new strings are now in the document.
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("FRED FRUMP").Count == 2);
|
|
|
|
Assert.IsTrue(replaceDoc.FindAll("cr-md-2011-1234567").Count == 2);
|
|
|
|
|
|
|
|
// Make sure the replacement worked.
|
|
|
|
Assert.IsTrue(replaceDoc.Text == "\t\t\t\t\t\t\t\t\t\t\t\t\t\tThese two tables should look identical:\t\t\t\t\t\t\t\t\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