Exemple #1
0
        public TestAssembly(TestEntry entry, string manifestName = "Microsoft.Extensions.FileProviders.Embedded.Manifest.xml")
        {
            ManifestName = manifestName;

            var manifest = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XElement("Manifest",
                             new XElement("ManifestVersion", "1.0"),
                             new XElement("FileSystem", entry.Children.Select(c => c.ToXElement()))));

            ManifestStream = new MemoryStream();
            using (var writer = XmlWriter.Create(ManifestStream, new XmlWriterSettings {
                CloseOutput = false
            }))
            {
                manifest.WriteTo(writer);
            }

            ManifestStream.Seek(0, SeekOrigin.Begin);
            Files = entry.GetFiles().Select(f => f.ResourcePath).ToArray();
        }