Exemple #1
0
        public async Task GetAllVersionsAsync_ReturnsAllVersions()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var versions = await test.Resource.GetAllVersionsAsync(
                    test.PackageIdentity.Id,
                    test.SourceCacheContext,
                    NullLogger.Instance,
                    CancellationToken.None);

                Assert.Equal(new[]
                {
                    NuGetVersion.Parse("0.1.0"),
                    NuGetVersion.Parse("0.2.0"),
                    NuGetVersion.Parse("0.3.0"),
                    NuGetVersion.Parse("0.4.0"),
                    NuGetVersion.Parse("0.5.0"),
                    NuGetVersion.Parse("0.6.0"),
                    NuGetVersion.Parse("0.7.0"),
                    NuGetVersion.Parse("0.8.0"),
                    NuGetVersion.Parse("0.9.0"),
                    NuGetVersion.Parse("0.10.0"),
                    NuGetVersion.Parse("0.11.0"),
                    NuGetVersion.Parse("0.12.0"),
                    NuGetVersion.Parse("1.0.0"),
                    NuGetVersion.Parse("1.1.0"),
                    NuGetVersion.Parse("1.1.1"),
                    NuGetVersion.Parse("1.2.0"),
                    NuGetVersion.Parse("1.3.0"),
                    NuGetVersion.Parse("1.4.0"),
                    NuGetVersion.Parse("1.4.0.1-rc")
                }, versions);
            }
        }
Exemple #2
0
 public async Task GetPackageDownloaderAsync_ThrowsIfCancelled()
 {
     using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
     {
         await Assert.ThrowsAsync <OperationCanceledException>(
             () => test.Resource.GetPackageDownloaderAsync(
                 new PackageIdentity(id: "a", version: NuGetVersion.Parse("1.0.0")),
                 test.SourceCacheContext,
                 NullLogger.Instance,
                 new CancellationToken(canceled: true)));
     }
 }
Exemple #3
0
 public async Task GetAllVersionsAsync_ThrowIfCancelled()
 {
     using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
     {
         await Assert.ThrowsAsync <OperationCanceledException>(
             () => test.Resource.GetAllVersionsAsync(
                 id: "a",
                 cacheContext: test.SourceCacheContext,
                 logger: NullLogger.Instance,
                 cancellationToken: new CancellationToken(canceled: true)));
     }
 }
Exemple #4
0
        public async Task GetPackageDownloaderAsync_ReturnsNullIfPackageNotFound()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var downloader = await test.Resource.GetPackageDownloaderAsync(
                    new PackageIdentity(id : "a", version : NuGetVersion.Parse("1.0.0")),
                    test.SourceCacheContext,
                    NullLogger.Instance,
                    CancellationToken.None);

                Assert.Null(downloader);
            }
        }
Exemple #5
0
        public async Task GetPackageDownloaderAsync_ReturnsPackageDownloaderIfPackageFound()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var downloader = await test.Resource.GetPackageDownloaderAsync(
                    test.PackageIdentity,
                    test.SourceCacheContext,
                    NullLogger.Instance,
                    CancellationToken.None);

                Assert.IsType <RemotePackageArchiveDownloader>(downloader);
            }
        }
Exemple #6
0
        public async Task GetAllVersionsAsync_ReturnsEmptyEnumerableIfPackageIdNotFound()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var versions = await test.Resource.GetAllVersionsAsync(
                    id : "a",
                    cacheContext : test.SourceCacheContext,
                    logger : NullLogger.Instance,
                    cancellationToken : CancellationToken.None);

                Assert.Empty(versions);
            }
        }
Exemple #7
0
 public async Task CopyNupkgToStreamAsync_ThrowsIfCancelled()
 {
     using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
     {
         await Assert.ThrowsAsync <OperationCanceledException>(
             () => test.Resource.CopyNupkgToStreamAsync(
                 id: "a",
                 version: NuGetVersion.Parse("1.0.0"),
                 destination: Stream.Null,
                 cacheContext: test.SourceCacheContext,
                 logger: NullLogger.Instance,
                 cancellationToken: new CancellationToken(canceled: true)));
     }
 }
Exemple #8
0
        public async Task GetDependencyInfoAsync_ReturnsNullIfPackageNotFound()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var dependencyInfo = await test.Resource.GetDependencyInfoAsync(
                    id : "a",
                    version : NuGetVersion.Parse("1.0.0"),
                    cacheContext : test.SourceCacheContext,
                    logger : NullLogger.Instance,
                    cancellationToken : CancellationToken.None);

                Assert.Null(dependencyInfo);
            }
        }
Exemple #9
0
        public async Task GetAllVersionsAsync_ThrowsForNullLogger()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentNullException>(
                    () => test.Resource.GetAllVersionsAsync(
                        id: "a",
                        cacheContext: test.SourceCacheContext,
                        logger: null,
                        cancellationToken: CancellationToken.None));

                Assert.Equal("logger", exception.ParamName);
            }
        }
Exemple #10
0
        public async Task GetPackageDownloaderAsync_ThrowsForNullLogger()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentNullException>(
                    () => test.Resource.GetPackageDownloaderAsync(
                        new PackageIdentity(id: "a", version: NuGetVersion.Parse("1.0.0")),
                        test.SourceCacheContext,
                        logger: null,
                        cancellationToken: CancellationToken.None));

                Assert.Equal("logger", exception.ParamName);
            }
        }
Exemple #11
0
        public async Task GetAllVersionsAsync_ThrowsForNullOrEmptyId(string id)
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentException>(
                    () => test.Resource.GetAllVersionsAsync(
                        id,
                        test.SourceCacheContext,
                        NullLogger.Instance,
                        CancellationToken.None));

                Assert.Equal("id", exception.ParamName);
            }
        }
Exemple #12
0
        public async Task GetPackageDownloaderAsync_ThrowsForNullPackageIdentity()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentNullException>(
                    () => test.Resource.GetPackageDownloaderAsync(
                        packageIdentity: null,
                        cacheContext: test.SourceCacheContext,
                        logger: NullLogger.Instance,
                        cancellationToken: CancellationToken.None));

                Assert.Equal("packageIdentity", exception.ParamName);
            }
        }
Exemple #13
0
        public async Task GetDependencyInfoAsync_ThrowsForNullSourceCacheContext()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentNullException>(
                    () => test.Resource.GetDependencyInfoAsync(
                        id: "a",
                        version: NuGetVersion.Parse("1.0.0"),
                        cacheContext: null,
                        logger: NullLogger.Instance,
                        cancellationToken: CancellationToken.None));

                Assert.Equal("cacheContext", exception.ParamName);
            }
        }
Exemple #14
0
        public async Task CopyNupkgToStreamAsync_ThrowsForNullId(string id)
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentException>(
                    () => test.Resource.CopyNupkgToStreamAsync(
                        id,
                        NuGetVersion.Parse("1.0.0"),
                        Stream.Null,
                        test.SourceCacheContext,
                        NullLogger.Instance,
                        CancellationToken.None));

                Assert.Equal("id", exception.ParamName);
            }
        }
Exemple #15
0
        public async Task CopyNupkgToStreamAsync_ThrowsForNullLogger()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentNullException>(
                    () => test.Resource.CopyNupkgToStreamAsync(
                        id: "a",
                        version: NuGetVersion.Parse("1.0.0"),
                        destination: Stream.Null,
                        cacheContext: test.SourceCacheContext,
                        logger: null,
                        cancellationToken: CancellationToken.None));

                Assert.Equal("logger", exception.ParamName);
            }
        }
Exemple #16
0
        public async Task CopyNupkgToStreamAsync_ReturnsFalseIfNotCopied()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
                using (var stream = new MemoryStream())
                {
                    var wasCopied = await test.Resource.CopyNupkgToStreamAsync(
                        id : "a",
                        version : NuGetVersion.Parse("1.0.0"),
                        destination : stream,
                        cacheContext : test.SourceCacheContext,
                        logger : NullLogger.Instance,
                        cancellationToken : CancellationToken.None);

                    Assert.False(wasCopied);
                    Assert.Equal(0, stream.Length);
                }
        }
Exemple #17
0
        public async Task CopyNupkgToStreamAsync_ReturnsTrueIfCopied()
        {
            using (var test = HttpFileSystemBasedFindPackageByIdResourceTest.Create())
                using (var stream = new MemoryStream())
                {
                    var wasCopied = await test.Resource.CopyNupkgToStreamAsync(
                        test.PackageIdentity.Id,
                        test.PackageIdentity.Version,
                        stream,
                        test.SourceCacheContext,
                        NullLogger.Instance,
                        CancellationToken.None);

                    Assert.True(wasCopied);
                    Assert.Equal(test.Package.Length, stream.Length);
                }
        }