Exemplo n.º 1
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));
    }
Exemplo n.º 2
0
    public void GetResolver_RespectsModConfigUrls()
    {
        // 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>(), new CommonPackageResolverSettings()));

        // Assert
        Assert.Equal(1, resolver.Count);
        Assert.True(resolverFactory.TryGetConfigurationOrDefault(mod, out var config));
    }