public SnapInstallerTests(BaseFixturePackaging baseFixture) { _baseFixture = baseFixture; _snapOsMock = new Mock <ISnapOs>(); _coreRunLibMock = new Mock <ICoreRunLib>(); _snapCryptoProvider = new SnapCryptoProvider(); _snapAppReader = new SnapAppReader(); _snapAppWriter = new SnapAppWriter(); _snapEmbeddedResources = new SnapEmbeddedResources(); _snapFilesystem = new SnapFilesystem(); _snapOsProcessManager = new SnapOsProcessManager(); _snapPack = new SnapPack(_snapFilesystem, _snapAppReader, _snapAppWriter, _snapCryptoProvider, _snapEmbeddedResources); var snapExtractor = new SnapExtractor(_snapFilesystem, _snapPack, _snapEmbeddedResources); _snapInstaller = new SnapInstaller(snapExtractor, _snapPack, _snapOsMock.Object, _snapEmbeddedResources, _snapAppWriter); _snapReleaseBuilderContext = new SnapReleaseBuilderContext(_coreRunLibMock.Object, _snapFilesystem, _snapCryptoProvider, _snapEmbeddedResources, _snapPack); }
static int MainImplAsync([NotNull] string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } using var cts = new CancellationTokenSource(); ISnapOs snapOs; try { snapOs = SnapOs.AnyOs; } catch (PlatformNotSupportedException) { SnapLogger.Error($"Platform is not supported: {RuntimeInformation.OSDescription}"); return(1); } catch (Exception e) { SnapLogger.ErrorException("Exception thrown while initializing snap os", e); return(1); } snapOs.InstallExitSignalHandler(async() => { cts.Cancel(); await OnExitAsync(); }); var workingDirectory = Environment.CurrentDirectory; if (!workingDirectory.EndsWith(snapOs.Filesystem.DirectorySeparator)) { workingDirectory += snapOs.Filesystem.DirectorySeparator; } var toolWorkingDirectory = snapOs.Filesystem.PathGetDirectoryName(typeof(Program).Assembly.Location); var snapCryptoProvider = new SnapCryptoProvider(); var snapEmbeddedResources = new SnapEmbeddedResources(); snapEmbeddedResources.ExtractCoreRunLibAsync(snapOs.Filesystem, snapCryptoProvider, toolWorkingDirectory, snapOs.OsPlatform).GetAwaiter().GetResult(); var snapXEmbeddedResources = new SnapxEmbeddedResources(); var coreRunLib = new CoreRunLib(snapOs.Filesystem, snapOs.OsPlatform, toolWorkingDirectory); var snapAppReader = new SnapAppReader(); var snapAppWriter = new SnapAppWriter(); var snapPack = new SnapPack(snapOs.Filesystem, snapAppReader, snapAppWriter, snapCryptoProvider, snapEmbeddedResources); var snapExtractor = new SnapExtractor(snapOs.Filesystem, snapPack, snapEmbeddedResources); var snapSpecsReader = new SnapAppReader(); var snapNetworkTimeProvider = new SnapNetworkTimeProvider("time.cloudflare.com", 123); var snapHttpClient = new SnapHttpClient(new HttpClient()); var nugetServiceCommandPack = new NugetService(snapOs.Filesystem, new NugetLogger(SnapPackLogger)); var nugetServiceCommandPromote = new NugetService(snapOs.Filesystem, new NugetLogger(SnapPromoteLogger)); var nugetServiceCommandDemote = new NugetService(snapOs.Filesystem, new NugetLogger(SnapDemoteLogger)); var nugetServiceCommandRestore = new NugetService(snapOs.Filesystem, new NugetLogger(SnapRestoreLogger)); var nugetServiceNoopLogger = new NugetService(snapOs.Filesystem, new NugetLogger(new LogProvider.NoOpLogger())); var snapPackageRestorer = new SnapPackageManager(snapOs.Filesystem, snapOs.SpecialFolders, nugetServiceCommandPack, snapHttpClient, snapCryptoProvider, snapExtractor, snapAppReader, snapPack); var distributedMutexClient = new DistributedMutexClient(new JsonServiceClient("https://snapx.dev")); Console.CancelKeyPress += async(sender, eventArgs) => { eventArgs.Cancel = !cts.IsCancellationRequested; cts.Cancel(); await OnExitAsync(); }; return(MainAsync(args, coreRunLib, snapOs, snapExtractor, snapOs.Filesystem, snapSpecsReader, snapCryptoProvider, snapPack, snapAppWriter, snapXEmbeddedResources, snapPackageRestorer, snapNetworkTimeProvider, nugetServiceCommandPack, nugetServiceCommandPromote, nugetServiceCommandDemote, nugetServiceCommandRestore, nugetServiceNoopLogger, distributedMutexClient, toolWorkingDirectory, workingDirectory, cts.Token)); }