Example #1
0
    public void GetResolver_DoesNotDuplicateFeeds()
    {
        // Arrange
        var mod = _testEnvironmoent.TestModConfigATuple;

        // Act
        var resolverFactory = new NuGetUpdateResolverFactory();

        resolverFactory.SetConfiguration(mod, new NuGetUpdateResolverFactory.NuGetConfig()
        {
            DefaultRepositoryUrls = new ObservableCollection <StringWrapper>()
            {
                "Sample Repository"
            }
        });

        using var disposalHelper = new RemoveConfiguration <NuGetUpdateResolverFactory.NuGetConfig>(mod, resolverFactory);

        var resolver = (AggregatePackageResolver)resolverFactory.GetResolver(mod, null, new UpdaterData(new List <string>()
        {
            "Sample Repository"
        }, new CommonPackageResolverSettings()));

        // Assert
        Assert.Equal(1, resolver.Count);
    }
Example #2
0
    public void Migrate_MigratesNuSpecIntoMainConfig()
    {
        // Arrange
        var mod            = _testEnvironmoent.TestModConfigATuple;
        var modDirectory   = Path.GetDirectoryName(mod.Path);
        var nuspecFilePath = Path.Combine(modDirectory !, $"{IOEx.ForceValidFilePath(mod.Config.ModId)}.nuspec");

        File.Create(nuspecFilePath).Dispose();

        // Act
        var factory = new NuGetUpdateResolverFactory();

        factory.Migrate(mod, null);
        using var disposalHelper = new RemoveConfiguration <NuGetUpdateResolverFactory.NuGetConfig>(mod, factory);

        // Assert
        Assert.False(File.Exists(nuspecFilePath));
        Assert.True(factory.TryGetConfigurationOrDefault(mod, out var config));
    }
Example #3
0
    public void Migrate_MigratesConfigIntoMainConfig()
    {
        // Arrange
        var mod          = _testEnvironmoent.TestModConfigATuple;
        var modDirectory = Path.GetDirectoryName(mod.Path);
        var configPath   = Path.Combine(modDirectory !, GitHubReleasesUpdateResolverFactory.GitHubConfig.ConfigFileName);
        var config       = new GitHubReleasesUpdateResolverFactory.GitHubConfig()
        {
        };

        IConfig <GitHubReleasesUpdateResolverFactory.GitHubConfig> .ToPath(config, configPath);

        // Act
        var factory = new GitHubReleasesUpdateResolverFactory();

        factory.Migrate(mod, null);
        using var disposalHelper = new RemoveConfiguration <GitHubReleasesUpdateResolverFactory.GitHubConfig>(mod, factory);

        // Assert
        Assert.False(File.Exists(configPath));
        Assert.True(factory.TryGetConfigurationOrDefault(mod, out _));
    }