public async Task TestGetMetadatasAsync_Local_Directory_PackageSource(NuGetProtocolVersion protocolVersion) { await using var packagesDirectory = new DisposableDirectory(_baseFixture.WorkingDirectory, _snapFilesystem); var packageSource = new PackageSource(packagesDirectory, "test", true) { ProtocolVersion = (int)protocolVersion }; var initialPackageIdentity = new PackageIdentity("test", NuGetVersion.Parse("1.0.0")); var initialPackageFilenameAbsolute = _snapFilesystem.PathCombine(packagesDirectory, $"{initialPackageIdentity.Id}.{initialPackageIdentity.Version.ToNormalizedString()}.nupkg"); await using (var packageOutputStream = _snapFilesystem.FileReadWrite(initialPackageFilenameAbsolute)) { await using var nupkgStream = BuildNupkg(initialPackageIdentity); await nupkgStream.CopyToAsync(packageOutputStream); } var secondPackageIdentity = new PackageIdentity("test", NuGetVersion.Parse("2.0.0")); var secondPackageFilenameAbsolute = _snapFilesystem.PathCombine(packagesDirectory, $"{secondPackageIdentity.Id}.{secondPackageIdentity.Version.ToNormalizedString()}.nupkg"); await using (var packageOutputStream = _snapFilesystem.FileReadWrite(secondPackageFilenameAbsolute)) { await using var nupkgStream = BuildNupkg(secondPackageIdentity); await nupkgStream.CopyToAsync(packageOutputStream); } var differentPackageIdentity = new PackageIdentity("test2", NuGetVersion.Parse("2.0.0")); var differentPackageFilenameAbsolute = _snapFilesystem.PathCombine(packagesDirectory, $"{differentPackageIdentity.Id}.{differentPackageIdentity.Version.ToNormalizedString()}.nupkg"); await using (var packageOutputStream = _snapFilesystem.FileReadWrite(differentPackageFilenameAbsolute)) { await using var nupkgStream = BuildNupkg(differentPackageIdentity); await nupkgStream.CopyToAsync(packageOutputStream); } var packageSources = new NuGetInMemoryPackageSources(packagesDirectory, packageSource); var packages = await _nugetService .GetMetadatasAsync("test", packageSources, false, cancellationToken : CancellationToken.None); Assert.Equal(2, packages.Count); }
static int CommandRcEdit([NotNull] RcEditOptions opts, [NotNull] ICoreRunLib coreRunLib, [NotNull] ISnapFilesystem snapFilesystem, [NotNull] ILog logger) { if (opts == null) { throw new ArgumentNullException(nameof(opts)); } if (coreRunLib == null) { throw new ArgumentNullException(nameof(coreRunLib)); } if (snapFilesystem == null) { throw new ArgumentNullException(nameof(snapFilesystem)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } var exitCode = 1; if (!snapFilesystem.FileExists(opts.Filename)) { logger.Error($"Filename does not exist: {opts.Filename}."); goto done; } if (opts.ConvertSubSystemToWindowsGui) { logger.Info($"Attempting to change subsystem to Windows GUI for executable: {snapFilesystem.PathGetFileName(opts.Filename)}."); using (var srcStream = snapFilesystem.FileReadWrite(opts.Filename, false)) { if (!srcStream.ChangeSubsystemToWindowsGui(SnapLogger)) { goto done; } logger.Info("Subsystem has been successfully changed to Windows GUI."); } exitCode = 0; } if (opts.IconFilename != null) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { logger.Error("Modifying executable icon is not supported on this OS platform."); goto done; } opts.IconFilename = snapFilesystem.PathGetFullPath(opts.IconFilename); if (!snapFilesystem.FileExists(opts.IconFilename)) { logger.Error($"Unable to find icon with filename: {opts.IconFilename}"); goto done; } if (!coreRunLib.SetIcon(opts.Filename, opts.IconFilename)) { logger.Error($"Unknown error setting icon for executable {opts.Filename}. Icon filename: {opts.Filename}."); goto done; } logger.Info("Icon has been successfully updated."); exitCode = 0; } done: return(exitCode); }