public async Task WhenUnlist_ReturnsTrueOnlyIfPackageExists(bool packageExists)
        {
            // Arrange
            var cancellationToken = CancellationToken.None;

            _options.PackageDeletionBehavior = PackageDeletionBehavior.Unlist;

            _packages
            .Setup(p => p.UnlistPackageAsync(PackageId, PackageVersion))
            .ReturnsAsync(packageExists);

            // Act
            var result = await _target.TryDeletePackageAsync(PackageId, PackageVersion, cancellationToken);

            // Assert
            Assert.Equal(packageExists, result);

            _packages.Verify(
                p => p.UnlistPackageAsync(PackageId, PackageVersion),
                Times.Once);

            _packages.Verify(
                p => p.HardDeletePackageAsync(It.IsAny <string>(), It.IsAny <NuGetVersion>()),
                Times.Never);
            _storage.Verify(
                s => s.DeleteAsync(It.IsAny <string>(), It.IsAny <NuGetVersion>(), cancellationToken),
                Times.Never);
        }
Пример #2
0
        public async Task WhenUnlist_ReturnsTrueOnlyIfPackageExists(bool packageExists)
        {
            // Arrange
            _options.PackageDeletionBehavior = PackageDeletionBehavior.Unlist;

            _packages
            .Setup(p => p.UnlistPackageAsync(new PackageIdentity(PackageId, PackageVersion)))
            .ReturnsAsync(packageExists);

            // Act
            var result = await _target.TryDeletePackageAsync(new PackageIdentity(PackageId, PackageVersion));

            // Assert
            Assert.Equal(packageExists, result);

            _packages.Verify(
                p => p.UnlistPackageAsync(new PackageIdentity(PackageId, PackageVersion)),
                Times.Once);

            _packages.Verify(
                p => p.HardDeletePackageAsync(It.IsAny <PackageIdentity>()),
                Times.Never);
            _storage.Verify(
                s => s.DeleteAsync(It.IsAny <PackageIdentity>()),
                Times.Never);
        }