Exemplo n.º 1
0
        public async Task VerifyNoEntriesWhenReadingAnEmptyCatalogAsync()
        {
            // Arrange
            using (var cache = new LocalCache())
                using (var cacheContext = new SourceCacheContext())
                    using (var workingDir = new TestFolder())
                    {
                        var log          = new TestLogger();
                        var baseUri      = Sleet.UriUtility.CreateUri("https://localhost:8080/testFeed/");
                        var feedFolder   = Path.Combine(workingDir, "feed");
                        var nupkgsFolder = Path.Combine(workingDir, "nupkgs");
                        Directory.CreateDirectory(feedFolder);
                        Directory.CreateDirectory(nupkgsFolder);

                        await CatalogReaderTestHelpers.CreateCatalogAsync(workingDir, feedFolder, nupkgsFolder, baseUri, log);

                        var feedUri = Sleet.UriUtility.CreateUri(baseUri.AbsoluteUri + "index.json");

                        var httpSource = CatalogReaderTestHelpers.GetHttpSource(cache, feedFolder, baseUri);

                        // Act
                        using (var catalogReader = new CatalogReader(feedUri, httpSource, cacheContext, TimeSpan.FromMinutes(1), log))
                        {
                            var entries = await catalogReader.GetEntriesAsync();

                            var flatEntries = await catalogReader.GetFlattenedEntriesAsync();

                            var set = await catalogReader.GetPackageSetAsync();

                            // Assert
                            Assert.Empty(entries);
                            Assert.Empty(flatEntries);
                            Assert.Empty(set);
                        }
                    }
        }