Ejemplo n.º 1
0
        public void TestGetContentTypes()
        {
            using (Stream s = new FileStream(TESTFILE_DIR + "test002.docx", FileMode.Open))
            {
                OPCPackage package = new OPCPackage(s);

                List<ContentTypeInfo> types = package.GetContentTypes();
                Assert.AreEqual(14, types.Count, "expected to find 14 contentTypes in the package");

                Assert.AreEqual("/word/footnotes.xml", types[0].Name);
                Assert.AreEqual("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", types[0].ContentType);
            }
        }
Ejemplo n.º 2
0
        public void TestNoContentTypeForExternalRels()
        {
            string sCopyFile = TESTFILE_DIR + "copy.docx";
            if (File.Exists(sCopyFile))
                File.Delete(sCopyFile);

            try
            {
                using (Stream str = File.Open(TESTFILE_DIR + "test002.docx", FileMode.Open))
                {
                    using (DocumentProcessor dp = new DocumentProcessor(str))
                    {

                        using (dp.Output = File.Open(sCopyFile, FileMode.CreateNew))
                        {

                            dp.Process(DocumentProcessingActions.PassThrough);
                        }
                    }
                }

                using (OPCPackage package = new OPCPackage(File.Open(sCopyFile, FileMode.Open)))
                {
                    List<ContentTypeInfo> ctilist = package.GetContentTypes();
                    foreach (ContentTypeInfo cti in ctilist)
                    {
                        Assert.IsFalse(cti.Name.StartsWith("file://"));
                        Assert.IsFalse(cti.Name.StartsWith("http://"));
                    }
                }
            }
            finally
            {
                File.Delete(sCopyFile);
            }
        }