public async Task GetAllVersionsAsync_ThrowIfCancelled() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { await Assert.ThrowsAsync <OperationCanceledException>( () => test.Resource.GetAllVersionsAsync( test.PackageIdentity.Id, test.SourceCacheContext, NullLogger.Instance, new CancellationToken(canceled: true))); } }
public async Task GetAllVersionsAsync_ReturnsEmptyEnumerableIfPackageIdNotFound() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var versions = await test.Resource.GetAllVersionsAsync( id : "b", cacheContext : test.SourceCacheContext, logger : NullLogger.Instance, cancellationToken : CancellationToken.None); Assert.Empty(versions); } }
public async Task GetPackageDownloaderAsync_ReturnsPackageDownloaderIfPackageFound() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var downloader = await test.Resource.GetPackageDownloaderAsync( test.PackageIdentity, test.SourceCacheContext, NullLogger.Instance, CancellationToken.None); Assert.IsType <LocalPackageArchiveDownloader>(downloader); } }
public async Task GetAllVersionsAsync_ReturnsAllVersions() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var versions = await test.Resource.GetAllVersionsAsync( test.PackageIdentity.Id, test.SourceCacheContext, NullLogger.Instance, CancellationToken.None); Assert.Equal(new[] { NuGetVersion.Parse("1.0.0") }, versions); } }
public async Task GetPackageDownloaderAsync_ReturnsNullIfPackageNotFound() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var downloader = await test.Resource.GetPackageDownloaderAsync( new PackageIdentity(id : "b", version : NuGetVersion.Parse("1.0.0")), test.SourceCacheContext, NullLogger.Instance, CancellationToken.None); Assert.Null(downloader); } }
public async Task GetAllVersionsAsync_ThrowsForNullLogger() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var exception = await Assert.ThrowsAsync <ArgumentNullException>( () => test.Resource.GetAllVersionsAsync( test.PackageIdentity.Id, test.SourceCacheContext, logger: null, cancellationToken: CancellationToken.None)); Assert.Equal("logger", exception.ParamName); } }
public async Task GetPackageDownloaderAsync_ThrowsForNullSourceCacheContext() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var exception = await Assert.ThrowsAsync <ArgumentNullException>( () => test.Resource.GetPackageDownloaderAsync( test.PackageIdentity, cacheContext: null, logger: NullLogger.Instance, cancellationToken: CancellationToken.None)); Assert.Equal("cacheContext", exception.ParamName); } }
public async Task GetAllVersionsAsync_ThrowsForNullOrEmptyId(string id) { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { 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_ReturnsNullIfPackageNotFound() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var dependencyInfo = await test.Resource.GetDependencyInfoAsync( id : "b", version : NuGetVersion.Parse("1.0.0"), cacheContext : test.SourceCacheContext, logger : NullLogger.Instance, cancellationToken : CancellationToken.None); Assert.Null(dependencyInfo); } }
public async Task GetDependencyInfoAsync_GetsOriginalIdentity() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var info = await test.Resource.GetDependencyInfoAsync( test.PackageIdentity.Id.ToUpper(), test.PackageIdentity.Version, test.SourceCacheContext, NullLogger.Instance, CancellationToken.None); Assert.Equal(test.PackageIdentity.Id.ToLower(), info.PackageIdentity.Id); Assert.Equal(test.PackageIdentity.Version, info.PackageIdentity.Version); } }
public async Task GetDependencyInfoAsync_ThrowsForNullVersion() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var exception = await Assert.ThrowsAsync <ArgumentNullException>( () => test.Resource.GetDependencyInfoAsync( test.PackageIdentity.Id, version: null, cacheContext: null, logger: NullLogger.Instance, cancellationToken: CancellationToken.None)); Assert.Equal("version", exception.ParamName); } }
public async Task CopyNupkgToStreamAsync_ThrowsForNullDestination() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) { var exception = await Assert.ThrowsAsync <ArgumentNullException>( () => test.Resource.CopyNupkgToStreamAsync( test.PackageIdentity.Id, test.PackageIdentity.Version, destination: null, cacheContext: test.SourceCacheContext, logger: NullLogger.Instance, cancellationToken: CancellationToken.None)); Assert.Equal("destination", exception.ParamName); } }
public async Task CopyNupkgToStreamAsync_ThrowsForNullId(string id) { using (var test = LocalV2FindPackageByIdResourceTest.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); } }
public async Task CopyNupkgToStreamAsync_ReturnsTrueIfCopied() { using (var test = LocalV2FindPackageByIdResourceTest.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); } }
public async Task CopyNupkgToStreamAsync_ReturnsFalseIfNotCopied() { using (var test = LocalV2FindPackageByIdResourceTest.Create()) using (var stream = new MemoryStream()) { var wasCopied = await test.Resource.CopyNupkgToStreamAsync( id : "b", 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); } }