Exemplo n.º 1
0
        public async Task GetInstalledSatelliteFilesAsync_ReturnsNullRuntimePackageDirectoryIfRuntimePackageDoesNotExist()
        {
            using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                using (var testDirectory = TestDirectory.Create())
                {
                    var packageIdentity      = new PackageIdentity("A", new NuGetVersion("1.2.3"));
                    var packagePathResolver  = new PackagePathResolver(testDirectory.Path);
                    var satellitePackageInfo = await TestPackagesCore.GetSatellitePackageAsync(
                        testDirectory.Path,
                        packageIdentity.Id,
                        packageIdentity.Version.ToNormalizedString(),
                        language : "fr");

                    using (var packageReader = new PackageArchiveReader(File.OpenRead(satellitePackageInfo.FullName)))
                    {
                        var result = await PackageHelper.GetInstalledSatelliteFilesAsync(
                            packageReader,
                            packagePathResolver,
                            PackageSaveMode.Defaultv3,
                            CancellationToken.None);

                        var runtimePackageDirectory = result.Item1;
                        var satelliteFiles          = result.Item2;

                        Assert.Null(runtimePackageDirectory);
                        Assert.Empty(satelliteFiles);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public async Task GetInstalledSatelliteFilesAsync_ReturnsEmptyEnumerableForNoInstalledSatelliteFiles()
        {
            using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                using (var testDirectory = TestDirectory.Create())
                {
                    var packageIdentity     = new PackageIdentity("A", new NuGetVersion("1.2.3"));
                    var packagePathResolver = new PackagePathResolver(testDirectory.Path);
                    var packageFileInfo     = await TestPackagesCore.GetRuntimePackageAsync(
                        testDirectory.Path,
                        packageIdentity.Id,
                        packageIdentity.Version.ToNormalizedString());

                    var satellitePackageInfo = await TestPackagesCore.GetSatellitePackageAsync(
                        testDirectory.Path,
                        packageIdentity.Id,
                        packageIdentity.Version.ToNormalizedString(),
                        language : "fr");

                    // Install runtime package
                    using (var packageReader = new PackageArchiveReader(File.OpenRead(packageFileInfo.FullName)))
                        using (var packageStream = File.OpenRead(packageFileInfo.FullName))
                        {
                            await PackageExtractor.ExtractPackageAsync(
                                test.Root,
                                packageReader,
                                packageStream,
                                packagePathResolver,
                                new PackageExtractionContext(
                                    PackageSaveMode.Defaultv2,
                                    PackageExtractionBehavior.XmlDocFileSaveMode,
                                    NullLogger.Instance,
                                    signedPackageVerifier : null,
                                    signedPackageVerifierSettings : null),
                                CancellationToken.None);
                        }

                    using (var packageReader = new PackageArchiveReader(File.OpenRead(satellitePackageInfo.FullName)))
                    {
                        var result = await PackageHelper.GetInstalledSatelliteFilesAsync(
                            packageReader,
                            packagePathResolver,
                            PackageSaveMode.Defaultv3,
                            CancellationToken.None);

                        var runtimePackageDirectory = result.Item1;
                        var satelliteFiles          = result.Item2;
                        var packageDirectoryName    = $"{packageIdentity.Id}.{packageIdentity.Version.ToNormalizedString()}";

                        Assert.Equal(Path.Combine(testDirectory.Path, packageDirectoryName), runtimePackageDirectory);
                        Assert.Empty(satelliteFiles);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public async Task GetItemsAsync_ReturnsItems()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = (await test.Reader.GetItemsAsync("other", CancellationToken.None)).ToArray();

                Assert.Equal(1, groups.Length);
                Assert.Equal(new[] { "other/net45/h", "other/net45/i" }, groups[0].Items);
                Assert.Equal(".NETFramework,Version=v4.5", groups[0].TargetFramework.DotNetFrameworkName);
            }
        }
Exemplo n.º 4
0
        public void GetItems_ReturnsItems()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = test.Reader.GetItems("other").ToArray();

                Assert.Equal(1, groups.Length);
                Assert.Equal(new[] { "other/net45/h", "other/net45/i" }, groups[0].Items);
                Assert.Equal(".NETFramework,Version=v4.5", groups[0].TargetFramework.DotNetFrameworkName);
            }
        }
Exemplo n.º 5
0
        public void GetLibItems_ReturnsLibItems()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = test.Reader.GetLibItems().ToArray();

                Assert.Equal(1, groups.Length);
                Assert.Equal(new[] { "lib/net45/d", "lib/net45/e", "lib/net45/f.dll", "lib/net45/g.dll" }, groups[0].Items);
                Assert.Equal(".NETFramework,Version=v4.5", groups[0].TargetFramework.DotNetFrameworkName);
            }
        }
Exemplo n.º 6
0
        public void GetBuildItems_ReturnsBuildItems()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = test.Reader.GetBuildItems().ToArray();

                Assert.Equal(1, groups.Length);
                Assert.Equal(new[] { "build/net45/a.props", "build/net45/a.targets" }, groups[0].Items);
                Assert.Equal(".NETFramework,Version=v4.5", groups[0].TargetFramework.DotNetFrameworkName);
            }
        }
Exemplo n.º 7
0
        public async Task GetFrameworkItemsAsync_ReturnsFrameworkItems()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = (await test.Reader.GetFrameworkItemsAsync(CancellationToken.None)).ToArray();

                Assert.Equal(2, groups.Length);
                Assert.Equal(new[] { "Z" }, groups[0].Items);
                Assert.Equal(".NETFramework,Version=v4.0", groups[0].TargetFramework.DotNetFrameworkName);
                Assert.Equal(new[] { "Y" }, groups[1].Items);
                Assert.Equal("Silverlight,Version=v3.0", groups[1].TargetFramework.DotNetFrameworkName);
            }
        }
Exemplo n.º 8
0
        public void GetFrameworkItems_ReturnsFrameworkItems()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = test.Reader.GetFrameworkItems().ToArray();

                Assert.Equal(2, groups.Length);
                Assert.Equal(new[] { "Z" }, groups[0].Items);
                Assert.Equal(".NETFramework,Version=v4.0", groups[0].TargetFramework.DotNetFrameworkName);
                Assert.Equal(new[] { "Y" }, groups[1].Items);
                Assert.Equal("Silverlight,Version=v3.0", groups[1].TargetFramework.DotNetFrameworkName);
            }
        }
Exemplo n.º 9
0
        public async Task GetInstalledPackageFilesAsync_ReturnsEmptyEnumerableIfNoPackageFilesInstalled()
        {
            using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var files = await PackageHelper.GetInstalledPackageFilesAsync(
                    test.Reader,
                    test.Reader.GetIdentity(),
                    test.Resolver,
                    PackageSaveMode.Defaultv3,
                    CancellationToken.None);

                Assert.Empty(files);
            }
        }
Exemplo n.º 10
0
        public async Task GetInstalledPackageFilesAsync_ReturnsInstalledPackageFiles()
        {
            using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                using (var packageStream = test.GetPackageStream())
                {
                    await PackageExtractor.ExtractPackageAsync(
                        test.Root,
                        test.Reader,
                        packageStream,
                        test.Resolver,
                        new PackageExtractionContext(
                            PackageSaveMode.Defaultv2,
                            PackageExtractionBehavior.XmlDocFileSaveMode,
                            clientPolicyContext : null,
                            logger : NullLogger.Instance),
                        CancellationToken.None);
                }

                var packageIdentity      = test.Reader.GetIdentity();
                var packageDirectoryName = $"{packageIdentity.Id}.{packageIdentity.Version.ToNormalizedString()}";

                // Delete some files so that the set of installed files is incomplete.
                Directory.Delete(Path.Combine(test.Root, packageDirectoryName, "lib"), recursive: true);

                var files = (await PackageHelper.GetInstalledPackageFilesAsync(
                                 test.Reader,
                                 test.Reader.GetIdentity(),
                                 test.Resolver,
                                 PackageSaveMode.Defaultv3,
                                 CancellationToken.None)).ToArray();

                Assert.Equal(9, files.Length);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "build/net45/a.dll"), files[0].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "build/net45/a.props"), files[1].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "build/net45/a.targets"), files[2].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "content/net45/b"), files[3].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "content/net45/c"), files[4].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "other/net45/h"), files[5].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "other/net45/i"), files[6].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "tools/net45/j"), files[7].FileFullPath);
                Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "tools/net45/k"), files[8].FileFullPath);
            }
        }
Exemplo n.º 11
0
        public async Task GetPackageDependenciesAsync_ReturnsPackageDependencies()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = (await test.Reader.GetPackageDependenciesAsync(CancellationToken.None)).ToArray();

                Assert.Equal(2, groups.Length);
                Assert.Equal(".NETFramework,Version=v4.0", groups[0].TargetFramework.DotNetFrameworkName);

                var packages = groups[0].Packages.ToArray();

                Assert.Equal(2, packages.Length);
                Assert.Equal("l", packages[0].Id);
                Assert.Equal("m", packages[1].Id);

                Assert.Empty(groups[1].Packages);
                Assert.Equal(".NETFramework,Version=v4.5", groups[1].TargetFramework.DotNetFrameworkName);
            }
        }
Exemplo n.º 12
0
        public void GetPackageDependencies_ReturnsPackageDependencies()
        {
            using (var test = PackageReaderTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage()))
            {
                var groups = test.Reader.GetPackageDependencies().ToArray();

                Assert.Equal(2, groups.Length);
                Assert.Equal(".NETFramework,Version=v4.0", groups[0].TargetFramework.DotNetFrameworkName);

                var packages = groups[0].Packages.ToArray();

                Assert.Equal(2, packages.Length);
                Assert.Equal("l", packages[0].Id);
                Assert.Equal("m", packages[1].Id);

                Assert.Empty(groups[1].Packages);
                Assert.Equal(".NETFramework,Version=v4.5", groups[1].TargetFramework.DotNetFrameworkName);
            }
        }