public void TestVisible() { Application app = new Application(); Assert.AreEqual(false, IsDVVisible()); app.Visible = true; Assert.AreEqual(true, IsDVVisible()); app.Visible = false; Assert.AreEqual(false, IsDVVisible()); app.Quit(false); }
public void TestRenderingSets() { Application app = new Application(); IStringCollection rsets = app.RenderingSetNames; Assert.IsNotNull(rsets); Assert.AreNotEqual(0, rsets.Count); app.Quit(false); }
public static void Main(string[] args) { // ensure path to file is absolute, not relative for both source files string original = args[0]; if (!Path.IsPathRooted(original)) original = Path.Combine(Environment.CurrentDirectory, original); string modified = args[1]; if (!Path.IsPathRooted(modified)) modified = Path.Combine(Environment.CurrentDirectory, modified); // create the application object and select the first available rendering set IApplication app = new Application(); app.OnApplicationClosed += new ApplicationClosedEventHandler(app_OnApplicationClosed); string renderingSet = app.RenderingSetNames[0]; // perform the comparison in standard mode IComparison comp = app.Comparisons.New(original, modified, renderingSet, ComparisonMode.Standard); comp.OnComparisonClosed += new ComparisonClosedEventHandler(comp_OnComparisonClosed); // save the redline string redlineFile = Path.GetTempFileName(); comp.SaveRedline(redlineFile, RedlineFileFormat.Pdf); // save the whole comparison as WDF then close string wdfFile = Path.GetTempFileName(); comp.SaveComparison(wdfFile); comp.Close(false); // make the app visible, then re-open the saved comparison app.Visible = true; comp = app.Comparisons.Open(wdfFile); // if we have any changes, go to the last one int iChangeCount = comp.Changes.Count; if (iChangeCount > 0) { IChange c = comp.Changes[iChangeCount-1]; string originalText = c.OriginalText; string modifiedText = c.ModifiedText; c.SynchronizeTo(); } // and done app.Visible = false; app.Quit(false); }
public void TestPerformComparison() { Application app = new Application(); Assert.AreEqual(false, IsDVVisible()); string saveFile = Path.GetTempFileName(); TestDoCompareAndSave(app, saveFile); Assert.AreEqual(0, app.Comparisons.Count); var comp2 = app.Comparisons.Open(saveFile); Assert.IsNotNull(comp2); Assert.AreEqual(1, app.Comparisons.Count); Assert.AreEqual(comp2, app.Comparisons[0], "Comparison object identity not maintained"); foreach (IComparison enumComp in app.Comparisons) { Assert.AreEqual(comp2, enumComp, "Comparison object identity not maintained"); } app.Quit(false); }
public void TestPerformComparisonsWithLongFileNames() { Application app = new Application(); Assert.AreEqual(false, IsDVVisible()); try { const int MAX = 252; string original = TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string root = TestFileUtils.RootPath; root = root.Replace('/', '\\'); string originalLong = @root + @"Test Files\188{0}.doc"; originalLong = string.Format(originalLong, new string('1', MAX - originalLong.Length)); string tempFile = originalLong; tempFile = @"\\?\" + tempFile; Assert.IsTrue(CopyFile(original, tempFile, false)); string modified = TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); string modifiedLong = @root + @"Test Files\220{0}.doc"; modifiedLong = string.Format(modifiedLong, new string('1', MAX - modifiedLong.Length)); tempFile = modifiedLong; tempFile = @"\\?\" + tempFile; Assert.IsTrue(CopyFile(modified, tempFile, false)); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.New(originalLong, modifiedLong, "Standard no moves", ComparisonMode.Standard, false); Assert.IsNotNull(comp); Assert.IsFalse(string.IsNullOrEmpty(comp.Name)); Assert.AreEqual(1, app.Comparisons.Count); Assert.AreEqual(comp, app.Comparisons[0], "Comparison object identity not maintained"); IComparison comp2 = app.Comparisons.New(modifiedLong, modifiedLong, "Standard no moves", ComparisonMode.Standard, false); Assert.IsNotNull(comp2); Assert.IsFalse(string.IsNullOrEmpty(comp2.Name)); Assert.AreEqual(2, app.Comparisons.Count); Assert.AreEqual(comp2, app.Comparisons[1], "Comparison object identity not maintained"); comp.Close(false); comp2.Close(false); comp = null; comp2 = null; DeleteFile(originalLong); DeleteFile(modifiedLong); Assert.AreEqual(0, app.Comparisons.Count); } catch (Exception e) { string err = e.Message; Assert.IsFalse(true, err); } finally { app.Quit(false); } }
public void TestVersion() { Application app = new Application(); Assert.AreEqual("0.0.0.0", app.Version, "workshare quirk - we use commas not dots"); app.Quit(false); }
public void TestOpen() { Application app = new Application(); Assert.AreEqual(false, IsDVVisible()); string sWdf = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\comparison.wdf"); IComparison comp = app.Comparisons.Open(sWdf); Assert.AreEqual(1, app.Comparisons.Count); Assert.AreEqual(comp, app.Comparisons[0], "Comparison object identity not maintained"); foreach (IComparison enumComp in app.Comparisons) { Assert.AreEqual(comp, enumComp, "Comparison object identity not maintained"); } Assert.IsFalse(string.IsNullOrEmpty(comp.RenderingSetName)); Assert.IsFalse(string.IsNullOrEmpty(comp.OriginalDocDescription)); Assert.IsFalse(string.IsNullOrEmpty(comp.OriginalDocId)); Assert.IsFalse(string.IsNullOrEmpty(comp.ModifiedDocDescription)); Assert.IsFalse(string.IsNullOrEmpty(comp.ModifiedDocId)); app.Quit(false); }
public void TestEventsNoAppFancyMarshalByRef() { Application app = new Application(); app.OnApplicationClosed += new ApplicationClosedEventHandler(app_OnApplicationClosed); Assert.AreEqual(false, IsDVVisible()); string sWdf = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\comparison.wdf"); IComparison comp = app.Comparisons.Open(sWdf); comp.OnComparisonClosed += new ComparisonClosedEventHandler(TestCompare_OnComparisonClosed); Assert.AreEqual(1, app.Comparisons.Count); app.Quit(false); }
public void TestSpecifyDocIds() { Application app = new Application(); string original = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string modified = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); string sTempOrig = Path.GetTempFileName(); string sTempMod = Path.GetTempFileName(); File.Copy(original, sTempOrig, true); File.Copy(modified, sTempMod, true); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.NewEx(sTempOrig, sTempMod, "Standard no moves", MakeDocId(original), MakeDocId(modified), ComparisonMode.Fast, false); Assert.IsNotNull(comp); Assert.AreEqual("original-modified", comp.Name); Assert.AreEqual(1, app.Comparisons.Count); Assert.AreEqual("file://" + original.Replace('\\', '/'), comp.OriginalDocId); Assert.AreEqual("file://" + modified.Replace('\\', '/'), comp.ModifiedDocId); comp.SwapOriginalModified(); Assert.AreEqual("modified-original", comp.Name); comp.Close(false); comp = null; app.Quit(false); }
public void TestSpecifyDescriptions() { Application app = new Application(); string original = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string modified = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.NewEx(original, modified, "Standard no moves", "one", "two", ComparisonMode.Fast, false); Assert.IsNotNull(comp); Assert.AreEqual("one-two" ,comp.Name); Assert.AreEqual(1, app.Comparisons.Count); Assert.AreEqual("file://" + original.Replace('\\', '/'), comp.OriginalDocId); Assert.AreEqual("file://" + modified.Replace('\\', '/'), comp.ModifiedDocId); Assert.AreEqual("one", comp.OriginalDocDescription); Assert.AreEqual("two", comp.ModifiedDocDescription); comp.SwapOriginalModified(); Assert.AreEqual("two-one", comp.Name); Assert.AreEqual("two", comp.OriginalDocDescription); Assert.AreEqual("one", comp.ModifiedDocDescription); comp.Close(false); comp = null; app.Quit(false); }
private static void TestDoCompareAndSave(Application app, string saveFile) { string original = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string modified = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.New(original, modified, "Standard no moves", ComparisonMode.Fast, false); Assert.IsNotNull(comp); Assert.IsFalse(string.IsNullOrEmpty(comp.Name)); Assert.AreEqual(1, app.Comparisons.Count); Assert.AreEqual(comp, app.Comparisons[0], "Comparison object identity not maintained"); foreach (IComparison enumComp in app.Comparisons) { Assert.AreEqual(comp, enumComp, "Comparison object identity not maintained"); } Assert.IsTrue(comp.SaveComparison(saveFile)); Assert.IsTrue(File.Exists(saveFile)); Assert.Greater(new FileInfo(saveFile).Length, 0); Assert.AreEqual("file://" + original.Replace('\\','/'), comp.OriginalDocId); Assert.AreEqual("file://" + modified.Replace('\\','/'), comp.ModifiedDocId); Assert.IsFalse(string.IsNullOrEmpty(comp.OriginalDocDescription)); Assert.IsFalse(string.IsNullOrEmpty(comp.ModifiedDocDescription)); Assert.IsFalse(string.IsNullOrEmpty(comp.RenderingSetName)); Assert.AreEqual("Standard no moves", comp.RenderingSetName); comp.Close(false); comp = null; }
public void TestChangeComparisonMode() { Application app = new Application(); Assert.AreEqual(false, IsDVVisible()); string original = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string modified = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.New(original, modified, "Standard no moves", ComparisonMode.Fast, false); app.Visible = true; Assert.IsNotNull(comp); Assert.IsFalse(string.IsNullOrEmpty(comp.Name)); comp.ChangeComparisonMode(ComparisonMode.TextOnly); app.Quit(false); }
public void TestChangeRenderingSet() { EventCounter ec = new EventCounter(); Application app = new Application(); app.OnApplicationClosed += new ApplicationClosedEventHandler(ec.OnApplicationClosed); try { Assert.AreEqual(false, IsDVVisible()); string original = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string modified = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.New(original, modified, "Standard no moves", ComparisonMode.Fast, false); comp.OnComparisonClosed += new ComparisonClosedEventHandler(ec.OnComparisonClosed); comp.OnComparisonRedone += new ComparisonRedoneEventHandler(ec.OnComparisonRedone); Assert.IsNotNull(comp); Assert.IsFalse(string.IsNullOrEmpty(comp.Name)); var changes = comp.Changes; Assert.AreNotEqual(0, changes.Count); bool seenTextBeforeChange = false; bool seenTextAfterChange = false; foreach (IChange c in changes) { Assert.IsNotNull(c); Assert.AreNotEqual(0, c.FirstChangeNumber); Assert.IsTrue(c.LastChangeNumber >= c.FirstChangeNumber); Assert.IsFalse(string.IsNullOrEmpty(c.OriginalText) && string.IsNullOrEmpty(c.ModifiedText), c.FirstChangeNumber.ToString()); seenTextBeforeChange |= !string.IsNullOrEmpty(c.TextBeforeChange); seenTextAfterChange |= !string.IsNullOrEmpty(c.TextAfterChange); } Assert.IsTrue(seenTextBeforeChange); Assert.IsTrue(seenTextAfterChange); Assert.AreEqual("Standard no moves", comp.RenderingSetName); comp.ChangeRenderingSet("Standard"); Assert.AreEqual(1, ec.Redone); Assert.Throws(typeof(COMException), delegate() { int i = changes.Count; }); Assert.AreEqual("Standard", comp.RenderingSetName); } finally { app.Quit(false); } }
public void TestSwap() { EventCounter ec = new EventCounter(); Application app = new Application(); app.OnApplicationClosed += new ApplicationClosedEventHandler(ec.OnApplicationClosed); try { Assert.AreEqual(false, IsDVVisible()); app.Visible = true; string original = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string modified = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.New(original, modified, "Standard no moves", ComparisonMode.Fast, false); comp.OnComparisonClosed += new ComparisonClosedEventHandler(ec.OnComparisonClosed); comp.OnComparisonRedone += new ComparisonRedoneEventHandler(ec.OnComparisonRedone); Assert.IsNotNull(comp); Assert.IsFalse(string.IsNullOrEmpty(comp.Name)); string name = comp.Name; IChangeCollection changes = comp.Changes; Assert.AreEqual(0, ec.Redone); comp.SwapOriginalModified(); Assert.AreEqual(1, ec.Redone); Assert.Throws(typeof(COMException), delegate() { int i = changes.Count; }); string newName = comp.Name; Assert.AreNotEqual(name, newName); Assert.AreEqual(0, ec.Closed); Assert.AreEqual(0, ec.AppClosed); } finally { app.Quit(false); } Assert.AreEqual(1, ec.AppClosed); Assert.AreEqual(1, ec.Closed); }
public void TestPerformTwoComparisons() { Application app = new Application(); Assert.AreEqual(false, IsDVVisible()); string original = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\original.doc"); string modified = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\modified.doc"); Assert.AreEqual(0, app.Comparisons.Count); IComparison comp = app.Comparisons.New(original, modified, "Standard no moves", ComparisonMode.Fast, false); Assert.IsNotNull(comp); Assert.IsFalse(string.IsNullOrEmpty(comp.Name)); Assert.AreEqual(1, app.Comparisons.Count); Assert.AreEqual(comp, app.Comparisons[0], "Comparison object identity not maintained"); IComparison comp2 = app.Comparisons.New(original, modified, "Standard no moves", ComparisonMode.Fast, false); Assert.IsNotNull(comp2); Assert.IsFalse(string.IsNullOrEmpty(comp2.Name)); Assert.AreEqual(2, app.Comparisons.Count); Assert.AreEqual(comp2, app.Comparisons[1], "Comparison object identity not maintained"); comp.Close(false); comp2.Close(false ); comp = null; comp2 = null; Assert.AreEqual(0, app.Comparisons.Count); app.Quit(false); }