public async Task Constructor_InitializesPropertyAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { Assert.Same(test.SourceRepository, test.Resource.SourceRepository); } }
public async Task GetPackageDownloaderAsync_ThrowsIfCancelledAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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))); } }
public async Task GetAllVersionsAsync_ThrowIfCancelledAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { await Assert.ThrowsAsync <OperationCanceledException>( () => test.Resource.GetAllVersionsAsync( id: "a", cacheContext: test.SourceCacheContext, logger: NullLogger.Instance, cancellationToken: new CancellationToken(canceled: true))); } }
public async Task GetAllVersionsAsync_ReturnsEmptyEnumerableIfPackageIdNotFoundAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { var versions = await test.Resource.GetAllVersionsAsync( id : "a", cacheContext : test.SourceCacheContext, logger : NullLogger.Instance, cancellationToken : CancellationToken.None); Assert.Empty(versions); } }
public async Task GetPackageDownloaderAsync_ReturnsNullIfPackageNotFoundAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task GetPackageDownloaderAsync_ReturnsPackageDownloaderIfPackageFoundAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { var downloader = await test.Resource.GetPackageDownloaderAsync( test.PackageIdentity, test.SourceCacheContext, NullLogger.Instance, CancellationToken.None); Assert.IsType <RemotePackageArchiveDownloader>(downloader); } }
public async Task GetAllVersionsAsync_ReturnsAllVersionsAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task GetPackageDownloaderAsync_ThrowsForNullPackageIdentityAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task CopyNupkgToStreamAsync_ThrowsIfCancelledAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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))); } }
public async Task GetDependencyInfoAsync_ReturnsNullIfPackageNotFoundAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task GetPackageDownloaderAsync_ThrowsForNullLoggerAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task GetAllVersionsAsync_ThrowsForNullLoggerAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { var exception = await Assert.ThrowsAsync <ArgumentNullException>( () => test.Resource.GetAllVersionsAsync( id: "a", cacheContext: test.SourceCacheContext, logger: null, cancellationToken: CancellationToken.None)); Assert.Equal("logger", exception.ParamName); } }
public async Task GetAllVersionsAsync_ThrowsForNullOrEmptyIdAsync(string id) { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { var exception = await Assert.ThrowsAsync <ArgumentException>( () => test.Resource.GetAllVersionsAsync( id, test.SourceCacheContext, NullLogger.Instance, CancellationToken.None)); Assert.Equal("id", exception.ParamName); } }
public async Task GetDependencyInfoAsync_ThrowsForNullSourceCacheContextAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task CopyNupkgToStreamAsync_ThrowsForNullIdAsync(string id) { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task CopyNupkgToStreamAsync_ThrowsForNullLoggerAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) { 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); } }
public async Task CopyNupkgToStreamAsync_ReturnsTrueIfCopiedAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) 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); } }
public async Task CopyNupkgToStreamAsync_ReturnsFalseIfNotCopiedAsync() { using (var test = await RemoteV3FindPackageByIdResourceTest.CreateAsync()) 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); } }