示例#1
0
 public SnapAppWriterTests(BaseFixture baseFixture)
 {
     _baseFixture    = baseFixture ?? throw new ArgumentNullException(nameof(baseFixture));
     _snapFilesystem = new SnapFilesystem();
     _snapAppWriter  = new SnapAppWriter();
     _snapAppReader  = new SnapAppReader();
 }
示例#2
0
 public SnapOsUnixTests(BaseFixture baseFixture)
 {
     _baseFixture    = baseFixture;
     _snapFilesystem = new SnapFilesystem();
     _snapOsUnix     = new SnapOsUnix(_snapFilesystem, new SnapOsProcessManager(), new SnapOsSpecialFoldersUnix());
     _snapOs         = new SnapOs(_snapOsUnix);
 }
示例#3
0
        static (SnapApps snapApps, SnapApp snapApp, bool error, string snapsAbsoluteFilename) BuildSnapAppFromDirectory(
            [NotNull] ISnapFilesystem filesystem, [NotNull] ISnapAppReader reader, [NotNull] INuGetPackageSources nuGetPackageSources,
            string id, [NotNull] string rid, [NotNull] string workingDirectory)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            if (rid == null)
            {
                throw new ArgumentNullException(nameof(rid));
            }
            if (nuGetPackageSources == null)
            {
                throw new ArgumentNullException(nameof(nuGetPackageSources));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            var(snapApps, snapAppTargets, _, snapsAbsoluteFilename) = BuildSnapAppsesFromDirectory(filesystem, reader, nuGetPackageSources, workingDirectory);
            var snapApp = snapAppTargets.SingleOrDefault(x => string.Equals(x.Id, id, StringComparison.OrdinalIgnoreCase) &&
                                                         string.Equals(x.Target.Rid, rid, StringComparison.OrdinalIgnoreCase));

            return(snapApps, snapApp, snapApps == null, snapsAbsoluteFilename);
        }
示例#4
0
 public SnapExtensionTests([NotNull] BaseFixture baseFixture)
 {
     _baseFixture = baseFixture ?? throw new ArgumentNullException(nameof(baseFixture));
     _appReader   = new SnapAppReader();
     _appWriter   = new SnapAppWriter();
     _fileSystem  = new SnapFilesystem();
 }
示例#5
0
        public DisposableDirectory(string workingDirectory, ISnapFilesystem filesystem, bool createRandomSubdirectory = true)
        {
            _filesystem      = filesystem;
            WorkingDirectory = !createRandomSubdirectory ? workingDirectory : filesystem.PathCombine(workingDirectory, Guid.NewGuid().ToString());

            filesystem.DirectoryCreateIfNotExists(WorkingDirectory);
        }
示例#6
0
        public NuGetMachineWideSettings([NotNull] ISnapFilesystem filesystem, [NotNull] string workingDirectory, ILog logger = null)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            logger ??= LogProvider.For <NuGetMachineWideSettings>();

            // https://github.com/NuGet/NuGet.Client/blob/8cb7886a7e9052308cfa51308f6f901c7caf5004/src/NuGet.Core/NuGet.Commands/SourcesCommands/SourceRunners.cs#L102

            _settings = new Lazy <ISettings>(() =>
            {
                ISettings settings;
                try
                {
                    settings = global::NuGet.Configuration.Settings.LoadDefaultSettings(workingDirectory,
                                                                                        configFileName: null,
                                                                                        machineWideSettings: new XPlatMachineWideSetting());
                }
                catch (NuGetConfigurationException ex) when(ex.InnerException is UnauthorizedAccessException)
                {
                    logger.ErrorException("Error loading machine wide settings", ex.InnerException ?? ex);
                    return(new NullSettings());
                }

                return(settings);
            });
        }
示例#7
0
 public NugetServiceTests([NotNull] BaseFixture baseFixture)
 {
     _baseFixture    = baseFixture ?? throw new ArgumentNullException(nameof(baseFixture));
     _snapFilesystem = new SnapFilesystem();
     _nugetService   = new NugetService(_snapFilesystem, new NugetLogger(new LogProvider.NoOpLogger()));
     _snapFilesystem = new SnapFilesystem();
 }
示例#8
0
        public NuGetMachineWidePackageSources([NotNull] ISnapFilesystem filesystem, [NotNull] string workingDirectory)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            var nugetMachineWideSettings = new NuGetMachineWideSettings(filesystem, workingDirectory);
            var packageSources           = new List <PackageSource>();

            var nugetConfigReader = new NuGetConfigFileReader();

            foreach (var packageSource in nugetConfigReader.ReadNugetSources(workingDirectory).Where(x => x.IsEnabled))
            {
                if (!packageSources.Contains(packageSource))
                {
                    packageSources.Add(packageSource);
                }
            }

            Items    = packageSources;
            Settings = nugetMachineWideSettings.Settings;
        }
示例#9
0
 public SnapAppReaderTests(BaseFixture baseFixture)
 {
     _baseFixture    = baseFixture;
     _snapAppReader  = new SnapAppReader();
     _snapAppWriter  = new SnapAppWriter();
     _snapFilesystem = new SnapFilesystem();
 }
示例#10
0
        static string BuildPackagesDirectory([NotNull] ISnapFilesystem filesystem, [NotNull] string workingDirectory, [NotNull] SnapAppsGeneric snapAppsGeneric,
                                             [NotNull] SnapApp snapApp)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }
            if (snapAppsGeneric == null)
            {
                throw new ArgumentNullException(nameof(snapAppsGeneric));
            }
            if (snapApp == null)
            {
                throw new ArgumentNullException(nameof(snapApp));
            }

            var properties = new Dictionary <string, string>
            {
                { "id", snapApp.Id },
                { "rid", snapApp.Target.Rid }
            };

            return(snapAppsGeneric.Packages == null?
                   filesystem.PathCombine(workingDirectory, ".snapx", "packages", "$id$/$rid$").ExpandProperties(properties) :
                       filesystem.PathGetFullPath(snapAppsGeneric.Packages).ExpandProperties(properties));
        }
示例#11
0
        static string BuildArtifactsDirectory([NotNull] ISnapFilesystem filesystem, [NotNull] string workingDirectory, [NotNull] SnapAppsGeneric snapAppsGeneric,
                                              [NotNull] SnapApp snapApp)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }
            if (snapAppsGeneric == null)
            {
                throw new ArgumentNullException(nameof(snapAppsGeneric));
            }
            if (snapApp == null)
            {
                throw new ArgumentNullException(nameof(snapApp));
            }

            var properties = new Dictionary <string, string>
            {
                { "id", snapApp.Id },
                { "rid", snapApp.Target.Rid },
                { "version", snapApp.Version.ToNormalizedString() }
            };

            return(snapAppsGeneric.Artifacts == null?
                   filesystem.PathCombine(workingDirectory, ".snapx", "artifacts", "$id$/$rid$/$version$").ExpandProperties(properties) :
                       filesystem.PathCombine(workingDirectory, snapAppsGeneric.Artifacts.ExpandProperties(properties)));
        }
示例#12
0
 public SnapOsWindows(ISnapFilesystem snapFilesystem, [JetBrains.Annotations.NotNull] ISnapOsProcessManager snapOsProcessManager,
                      [JetBrains.Annotations.NotNull] ISnapOsSpecialFolders snapOsSpecialFolders, bool isUnitTest = false)
 {
     Filesystem       = snapFilesystem ?? throw new ArgumentNullException(nameof(snapFilesystem));
     OsProcessManager = snapOsProcessManager ?? throw new ArgumentNullException(nameof(snapOsProcessManager));
     SpecialFolders   = snapOsSpecialFolders ?? throw new ArgumentNullException(nameof(snapOsSpecialFolders));
     _isUnitTest      = isUnitTest;
 }
示例#13
0
 internal DisposableDirectory WithDisposableTempDirectory([NotNull] ISnapFilesystem filesystem)
 {
     if (filesystem == null)
     {
         throw new ArgumentNullException(nameof(filesystem));
     }
     return(new DisposableDirectory(WorkingDirectory, filesystem));
 }
示例#14
0
 public SnapEmbeddedResourcesTests(BaseFixture baseFixture)
 {
     _coreRunLibMock        = new Mock <ICoreRunLib>();
     _baseFixture           = baseFixture;
     _snapCryptoProvider    = new SnapCryptoProvider();
     _snapFilesystem        = new SnapFilesystem();
     _snapEmbeddedResources = new SnapEmbeddedResources();
 }
示例#15
0
        public SnapOsUnix([NotNull] ISnapFilesystem filesystem, ISnapOsProcessManager snapOsProcessManager,
                          [NotNull] ISnapOsSpecialFolders snapOsSpecialFolders)
        {
            SpecialFolders   = snapOsSpecialFolders ?? throw new ArgumentNullException(nameof(snapOsSpecialFolders));
            OsProcessManager = snapOsProcessManager;
            Filesystem       = filesystem ?? throw new ArgumentNullException(nameof(filesystem));

            SnapOsUnixInit();
        }
示例#16
0
        static Task PushPackageAsync([NotNull] INugetService nugetService, [NotNull] ISnapFilesystem filesystem,
                                     [NotNull] IDistributedMutex distributedMutex, [NotNull] INuGetPackageSources nugetSources,
                                     [NotNull] PackageSource packageSource, SnapChannel channel, [NotNull] string packageAbsolutePath,
                                     CancellationToken cancellationToken,
                                     [NotNull] ILog logger)
        {
            if (nugetService == null)
            {
                throw new ArgumentNullException(nameof(nugetService));
            }
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (distributedMutex == null)
            {
                throw new ArgumentNullException(nameof(distributedMutex));
            }
            if (nugetSources == null)
            {
                throw new ArgumentNullException(nameof(nugetSources));
            }
            if (packageSource == null)
            {
                throw new ArgumentNullException(nameof(packageSource));
            }
            if (packageAbsolutePath == null)
            {
                throw new ArgumentNullException(nameof(packageAbsolutePath));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (!filesystem.FileExists(packageAbsolutePath))
            {
                throw new FileNotFoundException(packageAbsolutePath);
            }

            var packageName = filesystem.PathGetFileName(packageAbsolutePath);

            return(SnapUtility.RetryAsync(async() =>
            {
                if (!distributedMutex.Acquired)
                {
                    throw new Exception("Distributed mutex has expired. This is most likely due to intermittent internet connection issues " +
                                        "or another user is attempting to publish a new version. Please retry pack operation.");
                }

                logger.Info($"Pushing {packageName} to channel {channel.Name} using package source {packageSource.Name}");
                var pushStopwatch = new Stopwatch();
                pushStopwatch.Restart();
                await nugetService.PushAsync(packageAbsolutePath, nugetSources, packageSource, null, cancellationToken: cancellationToken);
                logger.Info($"Pushed {packageName} to channel {channel.Name} using package source {packageSource.Name} in {pushStopwatch.Elapsed.TotalSeconds:0.0}s.");
            }));
        }
示例#17
0
 public NugetServiceV3Tests(BaseFixture baseFixture)
 {
     _baseFixture           = baseFixture;
     _coreRunLibMock        = new Mock <ICoreRunLib>();
     _snapEmbeddedResources = new SnapEmbeddedResources();
     _snapCryptoProvider    = new SnapCryptoProvider();
     _snapFilesystem        = new SnapFilesystem();
     _nugetService          = new NugetService(_snapFilesystem, new NugetLogger(new LogProvider.NoOpLogger()));
     _snapPack = new SnapPack(_snapFilesystem, new SnapAppReader(), new SnapAppWriter(), _snapCryptoProvider, new SnapEmbeddedResources());
 }
示例#18
0
 public SnapReleaseBuilderContext([NotNull] ICoreRunLib coreRunLib, [NotNull] ISnapFilesystem snapFilesystem,
                                  [NotNull] ISnapCryptoProvider snapCryptoProvider, [NotNull] ISnapEmbeddedResources snapEmbeddedResources,
                                  [NotNull] ISnapPack snapPack)
 {
     CoreRunLib            = coreRunLib ?? throw new ArgumentNullException(nameof(coreRunLib));
     SnapFilesystem        = snapFilesystem ?? throw new ArgumentNullException(nameof(snapFilesystem));
     SnapCryptoProvider    = snapCryptoProvider ?? throw new ArgumentNullException(nameof(snapCryptoProvider));
     SnapEmbeddedResources = snapEmbeddedResources ?? throw new ArgumentNullException(nameof(snapEmbeddedResources));
     SnapPack = snapPack ?? throw new ArgumentNullException(nameof(snapPack));
 }
示例#19
0
        static async Task <int> CommandLock([NotNull] LockOptions lockOptions, [NotNull] IDistributedMutexClient distributedMutexClient,
                                            [NotNull] ISnapFilesystem filesystem, [NotNull] ISnapAppReader appReader,
                                            [NotNull] ILog logger, [NotNull] string workingDirectory, CancellationToken cancellationToken)
        {
            if (lockOptions == null)
            {
                throw new ArgumentNullException(nameof(lockOptions));
            }
            if (distributedMutexClient == null)
            {
                throw new ArgumentNullException(nameof(distributedMutexClient));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            var snapApps = BuildSnapAppsFromDirectory(filesystem, appReader, workingDirectory);

            var snapApp = snapApps.Apps.FirstOrDefault(x => string.Equals(x.Id, lockOptions.Id, StringComparison.OrdinalIgnoreCase));

            if (snapApp == null)
            {
                logger.Error($"Unable to find application with id: {lockOptions.Id}.");
                return(1);
            }

            MaybeOverrideLockToken(snapApps, logger, lockOptions.Id, lockOptions.Token, "--token");

            if (string.IsNullOrWhiteSpace(snapApps.Generic.Token))
            {
                logger.Error("Please specify a token in your snapx.yml file. A random UUID is sufficient.");
                return(1);
            }

            await using var distributedMutex = WithDistributedMutex(distributedMutexClient,
                                                                    logger, snapApps.BuildLockKey(snapApp), cancellationToken, false);

            bool success;

            if (!lockOptions.Release)
            {
                success = await distributedMutex.TryAquireAsync();

                return(success ? 0 : 1);
            }

            success = await DistributedMutex.TryForceReleaseAsync(distributedMutex.Name, distributedMutexClient, logger);

            return(success ? 0 : 1);
        }
示例#20
0
        static (SnapApps snapApps, List <SnapApp> snapAppTargets, bool error, string snapsAbsoluteFilename) BuildSnapAppsesFromDirectory(
            [NotNull] ISnapFilesystem filesystem, [NotNull] ISnapAppReader reader, [NotNull] INuGetPackageSources nuGetPackageSources,
            [NotNull] string workingDirectory)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            if (nuGetPackageSources == null)
            {
                throw new ArgumentNullException(nameof(nuGetPackageSources));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            var snapsFilename = filesystem.PathCombine(workingDirectory, ".snapx", SnapxYamlFilename);

            try
            {
                var snapApps = BuildSnapAppsFromDirectory(filesystem, reader, workingDirectory);
                if (snapApps == null)
                {
                    goto error;
                }

                const int expectedSchemaVersion = 1;
                if (snapApps.Schema != expectedSchemaVersion)
                {
                    throw new Exception($"Invalid schema version: {snapApps.Schema}. Expected schema version: {expectedSchemaVersion}.");
                }

                snapApps.Generic ??= new SnapAppsGeneric();

                return(snapApps, snapApps.BuildSnapApps(nuGetPackageSources, filesystem).ToList(), false, snapsFilename);
            }
            catch (YamlException yamlException)
            {
                var moreHelpfulExceptionMaybe = yamlException.InnerException ?? yamlException;
                SnapLogger.ErrorException($"{SnapxYamlFilename} file contains incorrect yaml syntax. Error message: {moreHelpfulExceptionMaybe.Message}.", moreHelpfulExceptionMaybe);
            }
            catch (Exception e)
            {
                SnapLogger.ErrorException($"Unknown error deserializing {SnapxYamlFilename}", e);
            }

error:
            return(new SnapApps(), new List <SnapApp>(), true, snapsFilename);
        }
示例#21
0
        public CoreRunLib([JetBrains.Annotations.NotNull] ISnapFilesystem filesystem, OSPlatform osPlatform, [JetBrains.Annotations.NotNull] string workingDirectory)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            if (!osPlatform.IsSupportedOsVersion())
            {
                throw new PlatformNotSupportedException();
            }

            _osPlatform = osPlatform;

            var filename = filesystem.PathCombine(workingDirectory, "libcorerun-");

            #if SNAP_BOOTSTRAP
            return;
            #endif

            var rid = osPlatform.BuildRid();
            if (osPlatform == OSPlatform.Windows)
            {
                filename += $"{rid}.dll";
                _libPtr   = NativeMethodsWindows.dlopen(filename);
            }
            else if (osPlatform == OSPlatform.Linux)
            {
                filename += $"{rid}.so";
                _libPtr   = NativeMethodsUnix.dlopen(filename, NativeMethodsUnix.libdl_RTLD_NOW | NativeMethodsUnix.libdl_RTLD_LOCAL);
            }

            if (_libPtr == IntPtr.Zero)
            {
                throw new FileNotFoundException($"Failed to load corerun: {filename}. " +
                                                $"OS: {osPlatform}. " +
                                                $"64-bit OS: {Environment.Is64BitOperatingSystem}. " +
                                                $"Last error: {Marshal.GetLastWin32Error()}.");
            }

            // generic
            pal_is_elevated = new Delegate <pal_is_elevated_delegate>(_libPtr, osPlatform);
            pal_set_icon    = new Delegate <pal_set_icon_delegate>(_libPtr, osPlatform);

            // filesystem
            pal_fs_chmod       = new Delegate <pal_fs_chmod_delegate>(_libPtr, osPlatform);
            pal_fs_file_exists = new Delegate <pal_fs_file_exists_delegate>(_libPtr, osPlatform);
        }
示例#22
0
        static string BuildPackagesDirectory([NotNull] ISnapFilesystem filesystem, [NotNull] string workingDirectory)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }

            return(filesystem.PathCombine(workingDirectory, ".snapx", "packages"));
        }
示例#23
0
 public SnapCryptoProviderTests(BaseFixturePackaging baseFixture)
 {
     _baseFixture           = baseFixture;
     _snapCryptoProvider    = new SnapCryptoProvider();
     _snapAppReader         = new SnapAppReader();
     _snapAppWriter         = new SnapAppWriter();
     _snapEmbeddedResources = new SnapEmbeddedResources();
     _snapFilesystem        = new SnapFilesystem();
     _snapPack = new SnapPack(_snapFilesystem, _snapAppReader,
                              _snapAppWriter, _snapCryptoProvider, _snapEmbeddedResources, new SnapBinaryPatcher());
     _coreRunLibMock            = new Mock <ICoreRunLib>();
     _snapReleaseBuilderContext = new SnapReleaseBuilderContext(_coreRunLibMock.Object,
                                                                _snapFilesystem, _snapCryptoProvider, _snapEmbeddedResources, _snapPack);
 }
示例#24
0
 public SnapOsSpecialFoldersUnitTest([NotNull] ISnapFilesystem snapFilesystem, [NotNull] string workingDirectory)
 {
     if (workingDirectory == null)
     {
         throw new ArgumentNullException(nameof(workingDirectory));
     }
     _snapFilesystem      = snapFilesystem ?? throw new ArgumentNullException(nameof(snapFilesystem));
     _disposableDirectory = new DisposableDirectory(workingDirectory, _snapFilesystem);
     _snapFilesystem.DirectoryCreateIfNotExists(ApplicationData);
     _snapFilesystem.DirectoryCreateIfNotExists(LocalApplicationData);
     _snapFilesystem.DirectoryCreateIfNotExists(StartupDirectory);
     _snapFilesystem.DirectoryCreateIfNotExists(StartMenu);
     _snapFilesystem.DirectoryCreateIfNotExists(InstallerCacheDirectory);
     _snapFilesystem.DirectoryCreateIfNotExists(NugetCacheDirectory);
 }
 public static string GetFullPath(this AssemblyDefinition assemblyDefinition, [NotNull] ISnapFilesystem filesystem, [NotNull] string workingDirectory, OSPlatform osPlatform = default)
 {
     if (assemblyDefinition == null)
     {
         throw new ArgumentNullException(nameof(assemblyDefinition));
     }
     if (filesystem == null)
     {
         throw new ArgumentNullException(nameof(filesystem));
     }
     if (workingDirectory == null)
     {
         throw new ArgumentNullException(nameof(workingDirectory));
     }
     return(filesystem.PathCombine(workingDirectory, assemblyDefinition.BuildRelativeFilename(osPlatform)));
 }
示例#26
0
文件: SnapOs.cs 项目: hutterm/snapx
 public SnapOs(ISnapFilesystem snapFilesystem, ISnapOsProcessManager snapOsProcessManager, string workingDirectory, bool isUnitTest)
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         OsImpl = new SnapOsWindows(snapFilesystem, snapOsProcessManager, isUnitTest ?
                                    (ISnapOsSpecialFolders) new SnapOsSpecialFoldersUnitTest(snapFilesystem, workingDirectory) : new SnapOsSpecialFoldersWindows(), isUnitTest);
     }
     else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
     {
         OsImpl = new SnapOsUnix(snapFilesystem, snapOsProcessManager, isUnitTest ?
                                 (ISnapOsSpecialFolders) new SnapOsSpecialFoldersUnitTest(snapFilesystem, workingDirectory) : new SnapOsSpecialFoldersUnix());
     }
     else
     {
         throw new PlatformNotSupportedException();
     }
 }
示例#27
0
        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);
        }
 public SnapPackageManagerRestoreStrategyInstallOrUpdateTests(BaseFixturePackaging baseFixturePackaging, BaseFixtureNuget baseFixtureNuget)
 {
     _nugetServiceMock      = new Mock <INugetService>();
     _coreRunLibMock        = new Mock <ICoreRunLib>();
     _snapHttpClientMock    = new Mock <ISnapHttpClient>();
     _baseFixturePackaging  = baseFixturePackaging;
     _baseFixtureNuget      = baseFixtureNuget;
     _snapFilesystem        = new SnapFilesystem();
     _snapCryptoProvider    = new SnapCryptoProvider();
     _snapAppWriter         = new SnapAppWriter();
     _snapAppReader         = new SnapAppReader();
     _snapEmbeddedResources = new SnapEmbeddedResources();
     _snapPack           = new SnapPack(_snapFilesystem, _snapAppReader, _snapAppWriter, _snapCryptoProvider, _snapEmbeddedResources);
     _snapExtractor      = new SnapExtractor(_snapFilesystem, _snapPack, _snapEmbeddedResources);
     _snapPackageManager = new SnapPackageManager(_snapFilesystem, new SnapOsSpecialFoldersUnix(), _nugetServiceMock.Object, _snapHttpClientMock.Object,
                                                  _snapCryptoProvider, _snapExtractor, _snapAppReader, _snapPack);
     _releaseBuilderContext = new SnapReleaseBuilderContext(_coreRunLibMock.Object, _snapFilesystem,
                                                            _snapCryptoProvider, _snapEmbeddedResources, _snapPack);
 }
示例#29
0
 public SnapUpdateManagerTests(BaseFixture baseFixture, BaseFixturePackaging baseFixturePackaging, BaseFixtureNuget baseFixtureNuget, ITestOutputHelper testOutputHelper)
 {
     _baseFixture           = baseFixture;
     _baseFixturePackaging  = baseFixturePackaging;
     _baseFixtureNuget      = baseFixtureNuget;
     _testOutputHelper      = testOutputHelper;
     _coreRunLibMock        = new Mock <ICoreRunLib>();
     _nugetServiceMock      = new Mock <INugetService>();
     _snapHttpClientMock    = new Mock <ISnapHttpClient>();
     _snapCryptoProvider    = new SnapCryptoProvider();
     _snapEmbeddedResources = new SnapEmbeddedResources();
     _snapFilesystem        = new SnapFilesystem();
     _snapAppWriter         = new SnapAppWriter();
     _snapPack = new SnapPack(_snapFilesystem, new SnapAppReader(),
                              new SnapAppWriter(), _snapCryptoProvider, _snapEmbeddedResources, new SnapBinaryPatcher());
     _snapOs                = new SnapOs(_snapFilesystem, new SnapOsProcessManager(), _baseFixturePackaging.WorkingDirectory, true);
     _snapExtractor         = new SnapExtractor(_snapFilesystem, _snapPack, _snapEmbeddedResources);
     _snapInstaller         = new SnapInstaller(_snapExtractor, _snapPack, _snapOs, _snapEmbeddedResources, _snapAppWriter);
     _releaseBuilderContext = new SnapReleaseBuilderContext(_coreRunLibMock.Object, _snapFilesystem,
                                                            _snapCryptoProvider, _snapEmbeddedResources, _snapPack);
 }
示例#30
0
        static INuGetPackageSources BuildNuGetPackageSources([NotNull] ISnapFilesystem filesystem, [NotNull] ILog logger)
        {
            if (filesystem == null)
            {
                throw new ArgumentNullException(nameof(filesystem));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            try
            {
                return(new NuGetMachineWidePackageSources(filesystem, filesystem.DirectoryWorkingDirectory()));
            }
            catch (Exception e)
            {
                logger.Error($"Exception thrown while parsing nuget sources: {e.Message}");
                return(null);
            }
        }