Пример #1
0
        public async Task UpdatePackageInfo()
        {
            using (var cache = new TestPipPackageCache()) {
                AssertUtil.ContainsExactly(await cache.TestGetAllPackageNamesAsync());

                var p = await cache.TestInjectPackageAsync("ptvsd==1.0");

                AssertUtil.ContainsExactly(await cache.TestGetAllPackageNamesAsync(), "ptvsd");

                var changes = new List <string>();
                p.PropertyChanged += (s, e) => { changes.Add(e.PropertyName); };

                await cache.UpdatePackageInfoAsync(p, CancellationToken.None);

                AssertUtil.ContainsExactly(changes, "Description", "UpgradeVersion");
                Assert.IsTrue(p.UpgradeVersion.CompareTo(p.Version) > 0,
                              string.Format("Expected {0} > {1}", p.UpgradeVersion, p.Version)
                              );
            }
        }
Пример #2
0
        public async Task SaveLoadCache()
        {
            var cachePath = Path.Combine(TestData.GetTempPath(randomSubPath: true), "pip.cache");

            using (var cache = new TestPipPackageCache(cachePath)) {
                AssertUtil.ContainsExactly(await cache.TestGetAllPackageNamesAsync());

                var p = await cache.TestInjectPackageAsync("azure==0.9");

                p.Description = "azure description";

                p = await cache.TestInjectPackageAsync("ptvsd==1.0");

                p.Description    = "ptvsd description";
                p.UpgradeVersion = p.Version;

                // Descriptions are URL encoded
                // Only UpgradeVersion is stored
                AssertUtil.ContainsExactly(await cache.TestGetAllPackageSpecsAsync(),
                                           "azure:azure%20description",
                                           "ptvsd==1.0:ptvsd%20description"
                                           );

                await cache.TestWriteCacheToDiskAsync();
            }

            using (var cache = new TestPipPackageCache(cachePath)) {
                AssertUtil.ContainsExactly(await cache.TestGetAllPackageNamesAsync());

                await cache.TestReadCacheFromDiskAsync();

                // Descriptions are not cached
                AssertUtil.ContainsExactly(await cache.TestGetAllPackageSpecsAsync(),
                                           "azure",
                                           "ptvsd==1.0"
                                           );
            }
        }