Exemple #1
0
 public void TestSimpleCleanTo()
 {
     string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");
     using (TempFile tf = new TempFile(testDoc))
     {
         using (TempFile dest = new TempFile())
         {
             File.Delete(dest.FilePath);
             string initialHash = tf.MD5Sum;
             IPdfCleaner c = new PdfCleaner();
             c.CleanFileTo(tf.FilePath, dest.FilePath);
             Assert.IsTrue(File.Exists(dest.FilePath), "We expected the dest file to be created");
             string newHash = dest.MD5Sum;
             Assert.AreNotEqual(initialHash, newHash, "We expected the Cleanion to change the file contents");
         }
     }
 }
Exemple #2
0
        public void TestMissingInputFile()
        {
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\i_do_not_exist.pdf");
            using (TempFile dest = new TempFile())
            {
                File.Delete(dest.FilePath);
                PdfCleaner r = new PdfCleaner();
                try
                {
                    r.CleanFileTo(testDoc, dest.FilePath);
                    Assert.Fail("We expected not to get here - should have thrown an exception");
                }
                catch (Exception e)
                {
                    Assert.IsInstanceOf(typeof(FileNotFoundException), e);
                }
                Assert.IsFalse(File.Exists(dest.FilePath), "We expected the dest file not to be created");
            }

        }
Exemple #3
0
        public void TestLockedInputFile()
        {
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");
            using (TempFile tf = new TempFile(testDoc))
            using (TempFile dest = new TempFile())
            {
                File.Delete(dest.FilePath);
                using (Stream s = File.Open(tf.FilePath, FileMode.Open, FileAccess.ReadWrite))
                {
                    PdfCleaner r = new PdfCleaner();
                    try
                    {
                        r.CleanFileTo(tf.FilePath, dest.FilePath);
                        Assert.Fail("We expected not to get here - should have thrown an exception");
                    }
                    catch (Exception e)
                    {
                        //Assert.IsInstanceOf(typeof(IOException), e);
                    }
                    Assert.IsFalse(File.Exists(dest.FilePath), "We expected the dest file not to be created");
                }
            }

        }
Exemple #4
0
 public void TestRelativePath3()
 {
     string outputDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\output.pdf");
     IPdfCleaner c = new PdfCleaner();
     c.CleanFileTo("test.doc", outputDoc);
 }
Exemple #5
0
 public void TestBadOutputFile()
 {
     string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");
     using (TempFile tf = new TempFile(testDoc))
     {
         PdfCleaner r = new PdfCleaner();
         try
         {
             r.CleanFileTo(tf.FilePath, "q:\\blah\\no\\existy\\here.pdf");
             Assert.Fail("We expected not to get here - should have thrown an exception");
         }
         catch (Exception e)
         {
             //Assert.IsInstanceOf(typeof(IOException), e);
         }
     }
 }