示例#1
0
 public void Constructor_InitializesProperty()
 {
     using (var test = RemoteV3FindPackageByIdResourceTest.Create())
     {
         Assert.Same(test.SourceRepository, test.Resource.SourceRepository);
     }
 }
示例#2
0
 public async Task Constructor_InitializesPropertyAsync()
 {
     using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync())
     {
         Assert.Same(test.SourceRepository, test.Resource.SourceRepository);
     }
 }
示例#3
0
 public async Task GetAllVersionsAsync_ThrowIfCancelled()
 {
     using (var test = RemoteV3FindPackageByIdResourceTest.Create())
     {
         await Assert.ThrowsAsync <OperationCanceledException>(
             () => test.Resource.GetAllVersionsAsync(
                 id: "a",
                 cacheContext: test.SourceCacheContext,
                 logger: NullLogger.Instance,
                 cancellationToken: new CancellationToken(canceled: true)));
     }
 }
示例#4
0
 public async Task GetPackageDownloaderAsync_ThrowsIfCancelled()
 {
     using (var test = RemoteV3FindPackageByIdResourceTest.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)));
     }
 }
示例#5
0
        public async Task GetPackageDownloaderAsync_ReturnsNullIfPackageNotFound()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#6
0
        public async Task GetPackageDownloaderAsync_ReturnsPackageDownloaderIfPackageFound()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.Create())
            {
                var downloader = await test.Resource.GetPackageDownloaderAsync(
                    test.PackageIdentity,
                    test.SourceCacheContext,
                    NullLogger.Instance,
                    CancellationToken.None);

                Assert.IsType <RemotePackageArchiveDownloader>(downloader);
            }
        }
示例#7
0
        public async Task GetAllVersionsAsync_ReturnsAllVersions()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.Create())
            {
                var versions = await test.Resource.GetAllVersionsAsync(
                    test.PackageIdentity.Id,
                    test.SourceCacheContext,
                    NullLogger.Instance,
                    CancellationToken.None);

                Assert.Equal(new[] { NuGetVersion.Parse("2.2.0-beta1-build3239") }, versions);
            }
        }
示例#8
0
        public async Task GetAllVersionsAsync_ReturnsEmptyEnumerableIfPackageIdNotFound()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.Create())
            {
                var versions = await test.Resource.GetAllVersionsAsync(
                    id : "a",
                    cacheContext : test.SourceCacheContext,
                    logger : NullLogger.Instance,
                    cancellationToken : CancellationToken.None);

                Assert.Empty(versions);
            }
        }
示例#9
0
 public async Task GetDependencyInfoAsync_ThrowIfCancelledAsync()
 {
     using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync())
     {
         await Assert.ThrowsAsync <OperationCanceledException>(
             () => test.Resource.GetDependencyInfoAsync(
                 id: "a",
                 version: NuGetVersion.Parse("1.0.0"),
                 cacheContext: test.SourceCacheContext,
                 logger: NullLogger.Instance,
                 cancellationToken: new CancellationToken(canceled: true)));
     }
 }
示例#10
0
 public async Task CopyNupkgToStreamAsync_ThrowsIfCancelled()
 {
     using (var test = RemoteV3FindPackageByIdResourceTest.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)));
     }
 }
示例#11
0
        public async Task GetDependencyInfoAsync_ReturnsNullIfPackageNotFound()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#12
0
        public async Task GetPackageDownloaderAsync_ThrowsForNullPackageIdentity()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#13
0
        public async Task GetAllVersionsAsync_ThrowsForNullLogger()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#14
0
        public async Task GetAllVersionsAsync_ThrowsForNullOrEmptyId(string id)
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.Create())
            {
                var exception = await Assert.ThrowsAsync <ArgumentException>(
                    () => test.Resource.GetAllVersionsAsync(
                        id,
                        test.SourceCacheContext,
                        NullLogger.Instance,
                        CancellationToken.None));

                Assert.Equal("id", exception.ParamName);
            }
        }
示例#15
0
        public async Task GetPackageDownloaderAsync_ThrowsForNullLogger()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#16
0
        public async Task GetDependencyInfoAsync_ThrowsForNullSourceCacheContext()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#17
0
        public async Task CopyNupkgToStreamAsync_ThrowsForNullId(string id)
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#18
0
        public async Task CopyNupkgToStreamAsync_ThrowsForNullLogger()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
            }
        }
示例#19
0
        public async Task CopyNupkgToStreamAsync_ReturnsFalseIfNotCopied()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
                }
        }
示例#20
0
        public async Task CopyNupkgToStreamAsync_ReturnsTrueIfCopied()
        {
            using (var test = RemoteV3FindPackageByIdResourceTest.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);
                }
        }