Example #1
0
        public void CreateManifestTest()
        {
            var target = new OasisManifest();

            target.Add("file.doc", "application/msword");
            target.Add("datne.pdf", "application/pdf");
            target.Add("file2.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");

            var actual = target.Generate();

            Assert.Equal(@"<manifest:manifest xmlns:manifest=""urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"" manifest:version=""1.2"">" +
                         @"<manifest:file-entry manifest:full-path=""/"" manifest:media-type=""application/vnd.etsi.asic-e+zip"" />" +
                         @"<manifest:file-entry manifest:full-path=""file.doc"" manifest:media-type=""application/msword"" />" +
                         @"<manifest:file-entry manifest:full-path=""datne.pdf"" manifest:media-type=""application/pdf"" />" +
                         @"<manifest:file-entry manifest:full-path=""file2.docx"" manifest:media-type=""application/vnd.openxmlformats-officedocument.wordprocessingml.document"" />" +
                         @"</manifest:manifest>",
                         actual.ToString(SaveOptions.DisableFormatting));
        }
Example #2
0
        public void WriteManifest(IEnumerable <DataFile> dataFiles)
        {
            var manifest = new OasisManifest();

            foreach (var dataFile in dataFiles)
            {
                manifest.Add(dataFile.Name, dataFile.MimeType);
            }

            var entry = new ZipEntry($"{AsicContainer.MetaFolderName}/{AsicContainer.ManifestFileName}");

            _zipOutputStream.PutNextEntry(entry);

            manifest
            .Generate()
            .Save(_zipOutputStream);

            _zipOutputStream.CloseEntry();
        }
Example #3
0
        public void LoadManifestTest()
        {
            var manifest = XElement.Parse(@"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>
<manifest:manifest xmlns:manifest=""urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"" manifest:version=""1.2"">
<manifest:file-entry manifest:full-path=""/"" manifest:media-type=""application/vnd.etsi.asic-e+zip""/>
<manifest:file-entry manifest:full-path=""file.doc"" manifest:media-type=""application/msword""/>
<manifest:file-entry manifest:full-path=""file.docx"" manifest:media-type=""application/octet-stream""/>
<manifest:file-entry manifest:full-path=""file2.docx"" manifest:media-type=""application/octet-stream""/>
<manifest:file-entry manifest:full-path=""datne.pdf"" manifest:media-type=""application/pdf""/>
</manifest:manifest>");
            var target   = new OasisManifest(manifest);

            Assert.Equal(new Dictionary <string, string>
            {
                { "file.doc", "application/msword" },
                { "file.docx", "application/octet-stream" },
                { "file2.docx", "application/octet-stream" },
                { "datne.pdf", "application/pdf" },
            }, target.Files);
        }
Example #4
0
 private void ReadManifest(ZipEntry entry)
 {
     _manifest = new OasisManifest(XElement.Load(_zipInputStream));
 }