Esempio n. 1
0
        public void PackagesEndedWithResourcesShouldBeProcessed()
        {
            var packageName = "solution.resources";

            using (var packageFile = TestPackagesCore.GetLegacyResourcesPackage(packageName))
            {
                using (var zip = new ZipArchive(File.OpenRead(packageFile)))
                    using (var zipReader = new PackageArchiveReader(zip))
                    {
                        var folder = Path.Combine(Path.GetDirectoryName(packageFile), Guid.NewGuid().ToString());

                        using (var zipFile = new ZipArchive(File.OpenRead(packageFile)))
                        {
                            zipFile.ExtractAll(folder);

                            var folderReader = new PackageFolderReader(folder);

                            Assert.Equal(zipReader.GetIdentity(), folderReader.GetIdentity(), new PackageIdentityComparer());
                            var libs1 = zipReader.GetLibItems().Count();
                            var libs2 = folderReader.GetLibItems().Count();
                            Assert.Equal(libs1, libs2);

                            var group1 = zipReader.GetReferenceItems();
                            var group2 = folderReader.GetReferenceItems();

                            Assert.Equal(group1.Count(), group2.Count());

                            // Check that assemblies with the 'resource' in a title are not filtered out.
                            Assert.True(group1.First().Items.Any(p => p.EndsWith("resources.dll")));
                            // Check that resource assembly not filtered out.
                            Assert.True(group2.First().Items.Any(p => p.EndsWith("resources.dll")));

                            foreach (var item in group1)
                            {
                                Assert.False(item.Items.Any(p => p.EndsWith(packageName)));
                            }

                            foreach (var item in group2)
                            {
                                Assert.False(item.Items.Any(p => p.EndsWith(packageName)));
                            }
                        }
                    }
            }
        }