예제 #1
0
        public void TestAPIStructure()
        {
            bool foundType = false;
            bool foundItem = false;
            bool foundDetail = false;

            Discoverer d = new Discoverer();
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.doc");

            var result = d.DiscoverDocument(testDoc);
            IMetadataTypeCollection tc = result.GetMetadataTypesFound();
            foreach (MetadataType mt in tc)
            {
                foundType = true;
                var typeResult = result.GetItemsForType(mt);
                foreach (var item in typeResult)
                {
                    foundItem = true;
                    foreach (var detail in item.Details)
                    {
                        foundDetail = true;
                    }
                }
            }

            Assert.AreEqual(true, foundType, "No metadataTypes found");
            Assert.AreEqual(true, foundItem, "no items found");
            Assert.AreEqual(true, foundDetail, "no details found");
        }
예제 #2
0
        public static void Main(string[] args)
        {
            // ensure path to file is absolute, not relative
            string filename = args[0];
            if (!Path.IsPathRooted(filename))
                filename = Path.Combine(Environment.CurrentDirectory, filename);

            Discoverer d = new Discoverer();

            string xmlReport = d.DiscoverDocumentToXml(filename);
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(xmlReport);
            // process XML report
            
            string htmlReport = d.DiscoverDocumentToHtmlReport(filename);
            // display HTML report
        }
예제 #3
0
        public void TestSimpleCleanRtf()
        {
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.rtf");
            using (TempFile tf = new TempFile(testDoc))
            {
                string initialHash = tf.MD5Sum;
                IOfficeCleaner c = new OfficeCleaner();
                c.CleanFile(tf.FilePath);
                string newHash = tf.MD5Sum;
                Assert.AreNotEqual(initialHash, newHash, "We expected the Cleanion to change the file contents");

                Discoverer d = new Discoverer();
                using (var result = d.DiscoverDocument(tf.FilePath))
                {
                    Assert.IsFalse(result.HasMetadataOfType(MetadataType.TrackedChange));
                }

            }
        }
예제 #4
0
        public static void Main(string[] args)
        {
            // ensure path to file is absolute, not relative
            string filename = args[0];
            if (!Path.IsPathRooted(filename))
                filename = Path.Combine(Environment.CurrentDirectory, filename);

            Discoverer d = new Discoverer();

            using (IDiscoveryResult dr = d.DiscoverDocument(filename))
            {
                foreach (MetadataType mt in dr.GetMetadataTypesFound())
                {
                    Console.WriteLine(mt.ToString() + " : ");
                    foreach (IMetadataItem item in dr.GetItemsForType(mt))
                    {
                        foreach (IDetail detail in item.Details)
                        {
                            Console.WriteLine("\t" + detail.Name + " : " + detail.Value);
                        }
                    }
                }
            }
        }
예제 #5
0
		public void TestDiscoverAndRedact()
        {
            Discoverer d = new Discoverer();
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.doc");

            using (var result = d.DiscoverDocument(testDoc))
            {
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.HiddenText));
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.TrackedChange));
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.Header));
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.Footer));
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.DocumentStatistic));
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.BuiltInProperty));
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.Reviewer));

                Assert.IsNotNull(result.GetItemsForType(MetadataType.HiddenText));
                Assert.IsNull(result.GetItemsForType(MetadataType.HiddenSlide));
            }

            string cleanedDoc = Path.GetTempFileName();

            Redactor r = new Redactor();
            r.RedactFileTo(testDoc, cleanedDoc);

            using (var result = d.DiscoverDocument(cleanedDoc))
            {
                Assert.IsFalse(result.HasMetadataOfType(MetadataType.HiddenText));
                Assert.IsFalse(result.HasMetadataOfType(MetadataType.TrackedChange));
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.Header), "redact cannot clean headers");
                Assert.IsTrue(result.HasMetadataOfType(MetadataType.Footer), "redact cannot clean footers");
                Assert.IsFalse(result.HasMetadataOfType(MetadataType.DocumentStatistic));
                Assert.IsFalse(result.HasMetadataOfType(MetadataType.BuiltInProperty));
                Assert.IsFalse(result.HasMetadataOfType(MetadataType.Reviewer));
            }

        }
예제 #6
0
 public void TestRelativePath3()
 {
     IDiscoverer c = new Discoverer();
     c.DiscoverDocumentToXml("test.doc");
 }
예제 #7
0
		public void TestDiscoverPDF02()
		{
			Discoverer d = new Discoverer();
			string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\Comments_Bookmarks_Attachments_Markups.pdf");

			//Properties = 36, Attachments = 37, Bookmarks = 38, Markups = 39,
			using (var result = d.DiscoverDocument(testDoc))
			{
				Assert.IsNull(result.GetItemsForType(MetadataType.HiddenText));
				Assert.IsNull(result.GetItemsForType(MetadataType.HiddenSlide));


				Assert.IsFalse(result.HasMetadataOfType(MetadataType.HiddenText));
				Assert.IsFalse(result.HasMetadataOfType(MetadataType.TrackedChange));
				Assert.IsFalse(result.HasMetadataOfType(MetadataType.Header));
				Assert.IsFalse(result.HasMetadataOfType(MetadataType.Footer));
				Assert.IsFalse(result.HasMetadataOfType(MetadataType.DocumentStatistic));
				Assert.IsFalse(result.HasMetadataOfType(MetadataType.BuiltInProperty));
				Assert.IsFalse(result.HasMetadataOfType(MetadataType.Reviewer));

				Assert.IsTrue(result.HasMetadataOfType(MetadataType.Properties));
				Assert.IsTrue(result.GetItemsForType(MetadataType.Properties).Count == 7);

				Assert.IsTrue(result.HasMetadataOfType(MetadataType.Attachments));
				Assert.IsTrue(result.GetItemsForType(MetadataType.Attachments).Count == 1);

				Assert.IsTrue(result.HasMetadataOfType(MetadataType.Bookmarks));
				Assert.IsTrue(result.GetItemsForType(MetadataType.Bookmarks).Count == 4);
				
				Assert.IsTrue(result.HasMetadataOfType(MetadataType.Markups));
				Assert.IsTrue(result.GetItemsForType(MetadataType.Markups).Count > 13);

			}

		}
예제 #8
0
        public void TestDiscoverToXmlTwice()
        {
            Discoverer d = new Discoverer();
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.ppt");

            string report = d.DiscoverDocumentToXml(testDoc);
            Assert.IsFalse(string.IsNullOrEmpty(report));
            Assert.IsTrue(File.Exists(report));
            string report2 = d.DiscoverDocumentToXml(testDoc);
            Assert.IsFalse(string.IsNullOrEmpty(report2));
            Assert.IsTrue(File.Exists(report2));
            Assert.IsTrue(File.Exists(report));

            Assert.AreNotEqual(report, report2);
            File.Delete(report);
            File.Delete(report2);

        }
예제 #9
0
		public void TestDiscoverPDFToXmlAgain()
		{
			Discoverer d = new Discoverer();
			string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\Comments_Bookmarks_Attachments_Markups.pdf");

			string report = d.DiscoverDocumentToXml(testDoc);
			Assert.IsFalse(string.IsNullOrEmpty(report));
			Assert.IsTrue(File.Exists(report));
			string contents = File.ReadAllText(report);
			File.Delete(report);

			Assert.IsTrue(contents.StartsWith("<?"));	// which proves nothing :)
			Assert.IsTrue(contents.Length > 3000);
		}
예제 #10
0
 public void TestRelativePath2()
 {
     IDiscoverer c = new Discoverer();
     c.DiscoverDocumentToHtmlReport("test.doc");
 }
예제 #11
0
		public void TestDiscoverPDFToXml()
		{
			Discoverer d = new Discoverer();
			string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");

			string report = d.DiscoverDocumentToXml(testDoc);
			Assert.IsFalse(string.IsNullOrEmpty(report));
			Assert.IsTrue(File.Exists(report));
			string contents = File.ReadAllText(report);
			File.Delete(report);

			Assert.IsTrue(contents.StartsWith("<?"));
			Assert.IsTrue(contents.Length > 1000);
		}
예제 #12
0
		public void TestDiscoverPDFToHtml()
		{
			Discoverer d = new Discoverer();
			string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\Comments_Bookmarks_Attachments_Markups.pdf");

			string report = d.DiscoverDocumentToHtmlReport(testDoc);
			Assert.IsFalse(string.IsNullOrEmpty(report));
			Assert.IsTrue(File.Exists(report));
			string contents = File.ReadAllText(report);
			File.Delete(report);

			Assert.IsTrue(contents.StartsWith("<html "));
			Assert.IsTrue(contents.Length > 7000);
			// and can test for extant phrases of each type:
			Assert.IsTrue(contents.IndexOf("TextAnnotation on page") > 0);
			Assert.IsTrue(contents.IndexOf("Keywords: AcroTeX, AeB Pro, Acrobat annotations") > 0);
			Assert.IsTrue(contents.IndexOf("AAA.docx") > 0);
			Assert.IsTrue(contents.IndexOf("1 Introduction , links to page # 2") > 0);
		}