public void WhenPackageDoesNotExist_ThenThrowException()
            {
                var fileName = NugetPackageFileName.Create(ExistingPackageId, ExistingPackageVersion);
                var filePath = Path.Combine(BasePath, fileName);

                Assert.ThrowsAsync <NugetPackageNotFoundException>(() => _sut.DownloadToFileAsync(NonExistingPackageId, ExistingPackageVersion, filePath));
            }
            public async Task WhenPackageExists_ThenSaveLocally()
            {
                var fileName = NugetPackageFileName.Create(ExistingPackageId, ExistingPackageVersion);
                var filePath = Path.Combine(BasePath, fileName);

                await _sut.DownloadToFileAsync(ExistingPackageId, ExistingPackageVersion, filePath);

                AssertFile.Exists(filePath);
                AssertFile.SizeGreaterThan(filePath, 0);
            }
            public async Task WhenFileAlreadyExists_ThenOverWrite()
            {
                var fileName = NugetPackageFileName.Create(ExistingPackageId, ExistingPackageVersion);
                var filePath = Path.Combine(BasePath, fileName);

                TextFileTestBuilder.InFileSystem.WithSize(1).WithFilePath(filePath).Build();

                await _sut.DownloadToFileAsync(ExistingPackageId, ExistingPackageVersion, filePath);

                AssertFile.SizeGreaterThan(filePath, 1);
            }
            public void WhenArgsValid_ThenReturnFileName()
            {
                var result = NugetPackageFileName.Create(ValidId, "1.0.0");

                Assert.That(result, Is.EqualTo("Newtonsoft.Json.1.0.0.nupkg"));
            }
 public void WhenVersionIsNullOrEmpty_ThenThrowException(string version)
 {
     Assert.Throws <ArgumentException>(() => NugetPackageFileName.Create(ValidId, version));
 }
 public void WhenIdIsNullOrEmpty_ThenThrowException(string id)
 {
     Assert.Throws <ArgumentException>(() => NugetPackageFileName.Create(id, ValidVersion));
 }
 public void WhenVersionIsNull_ThenThrowException()
 {
     Assert.Throws <ArgumentNullException>(() => NugetPackageFileName.Create(ValidId, null as NuGetVersion));
 }