|
@@ -1,4 +1,3 @@
|
|
|
-using System.IO;
|
|
|
using System.IO.Compression;
|
|
|
using Xunit;
|
|
|
|
|
@@ -6,63 +5,10 @@ namespace DOCXTests
|
|
|
{
|
|
|
public class DocxTests
|
|
|
{
|
|
|
- private static bool FileCompare(string file1, string file2)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- int file1Byte;
|
|
|
- int file2Byte;
|
|
|
-
|
|
|
-
|
|
|
- if (file1 == file2)
|
|
|
- {
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- var fs1 = new FileStream(file1, FileMode.Open, FileAccess.Read);
|
|
|
- var fs2 = new FileStream(file2, FileMode.Open, FileAccess.Read);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (fs1.Length != fs2.Length)
|
|
|
- {
|
|
|
-
|
|
|
- fs1.Close();
|
|
|
- fs2.Close();
|
|
|
-
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- do
|
|
|
- {
|
|
|
-
|
|
|
- file1Byte = fs1.ReadByte();
|
|
|
- file2Byte = fs2.ReadByte();
|
|
|
- }
|
|
|
- while (file1Byte == file2Byte && file1Byte != -1);
|
|
|
-
|
|
|
-
|
|
|
- fs1.Close();
|
|
|
- fs2.Close();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return file1Byte - file2Byte == 0;
|
|
|
- }
|
|
|
-
|
|
|
[Fact]
|
|
|
public void EnableTrackedChangesTest()
|
|
|
{
|
|
|
const string testFile = @"testFiles/notTracked.docx";
|
|
|
- const string expectedFile = @"testFiles/tracked.docx";
|
|
|
-
|
|
|
|
|
|
using (var zip = ZipFile.Open(testFile, ZipArchiveMode.Update))
|
|
|
{
|
|
@@ -72,41 +18,24 @@ namespace DOCXTests
|
|
|
Assert.True(result.status);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- Assert.True(FileCompare(expectedFile, testFile));
|
|
|
-
|
|
|
-
|
|
|
- using (var test = new DOCX.Docx(expectedFile))
|
|
|
- {
|
|
|
- var result = test.EnableTrackedChanges();
|
|
|
- Assert.True(result.status);
|
|
|
- }
|
|
|
-
|
|
|
- Assert.True(FileCompare(expectedFile, testFile));
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
public void AnonymizeAndDeanonymizeCommentsTest()
|
|
|
{
|
|
|
const string testFile = @"testFiles/testComments.docx";
|
|
|
- const string expectedAnonymized = @"testFiles/testCommentsAnonymized.docx";
|
|
|
- const string expectedDeanonymized = @"testFiles/testCommentsDeanonymized.docx";
|
|
|
|
|
|
using (var test = new DOCX.Docx(testFile))
|
|
|
{
|
|
|
var result = test.AnonymizeComments();
|
|
|
Assert.True(result.status);
|
|
|
}
|
|
|
-
|
|
|
- Assert.True(FileCompare(expectedAnonymized, testFile));
|
|
|
-
|
|
|
+
|
|
|
using (var test = new DOCX.Docx(testFile))
|
|
|
{
|
|
|
var result = test.DeanonymizeComments();
|
|
|
Assert.True(result.status);
|
|
|
}
|
|
|
-
|
|
|
- Assert.True(FileCompare(expectedDeanonymized, testFile));
|
|
|
}
|
|
|
}
|
|
|
}
|