public void UsesPrereleaseColorOfPaletteAsBackgroundForNodeOfPrereleasePackage() { var packageUpgradePalette = new PackageUpgradePalette(); const string expected = "myColor"; packageUpgradePalette.PrereleaseColor = expected; var visualizer = new PackageUpgradeVisualizer(_directedGraph, packageUpgradePalette); var package = StubPackageFactory.CreatePackage("A", "1.0.0-a"); visualizer.Visualize(package, Enumerable.Empty <PackageUpgrade>()); Assert.Equal(expected, _directedGraph.Nodes[0].Background); }
public void UsesMissingPackageColorOfPaletteAsStrokeForNodeOfPackageDependency() { var packageUpgradePalette = new PackageUpgradePalette(); const string expected = "myColor"; packageUpgradePalette.MissingPackageColor = expected; var visualizer = new PackageUpgradeVisualizer(_directedGraph, packageUpgradePalette); var package = CreatePackage(); var packageUpgrade = CreatePackageUpgradeWithoutPackage(); visualizer.Visualize(package, new[] { packageUpgrade, }); var node = _directedGraph.Nodes[1]; Assert.Equal(expected, node.Stroke); }
/// <summary> /// Visualizes the upgradeable dependencies of the specified packages. /// </summary> /// <param name="packages">The packages.</param> /// <param name="repository">The repository to resolve package dependencies.</param> /// <param name="targetFramework">The framework to find compatible package dependencies.</param> /// <returns>The graph of the upgradeable dependencies of the specified packages.</returns> /// <exception cref="ArgumentNullException"><paramref name="packages"/> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="repository"/> is <c>null</c>.</exception> /// <seealso cref="UpgradeWalker"/> /// <seealso cref="PackageUpgradeVisualizer"/> /// <remarks> /// The method estimates the impact of an upgrade action. The palette ranges from green to red indicating the risk of an upgrade action. /// <list type="table"> /// <listheader> /// <term><see cref="PackageUpgradeAction"/></term> /// <term>Color</term> /// <term>Risk</term> /// </listheader> /// <item> /// <term><see cref="PackageUpgradeAction.None"/></term> /// <term>Black</term> /// <term>0</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.MinVersion"/></term> /// <term>ForestGreen</term> /// <term>1</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.ReleaseToRelease"/></term> /// <term>Goldenrod</term> /// <term>2</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.PrereleaseToRelease"/></term> /// <term>DarkOrange</term> /// <term>3</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.PrereleaseToPrerelease"/></term> /// <term>OrangeRed</term> /// <term>4</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.ReleaseToPrerelease"/></term> /// <term>Firebrick</term> /// <term>5</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.Unknown"/></term> /// <term>DarkGray</term> /// <term>-</term> /// </item> /// </list> /// </remarks> public static async Task <DirectedGraph> VisualizeUpgradeableDependenciesAsync( this IEnumerable <PackageIdentity> packages, SourceRepository repository, NuGetFramework targetFramework) { if (packages == null) { throw new ArgumentNullException(nameof(packages)); } if (repository == null) { throw new ArgumentNullException(nameof(repository)); } var walker = new UpgradeWalker(repository, targetFramework); var directedGraph = DirectedGraphFactory.CreateDependencyGraph(); var packageUpgradeActionPalette = new PackageUpgradeActionPalette(); packageUpgradeActionPalette[PackageUpgradeAction.None] = "Black"; packageUpgradeActionPalette[PackageUpgradeAction.MinVersion] = "ForestGreen"; packageUpgradeActionPalette[PackageUpgradeAction.ReleaseToRelease] = "Goldenrod"; packageUpgradeActionPalette[PackageUpgradeAction.PrereleaseToRelease] = "DarkOrange"; packageUpgradeActionPalette[PackageUpgradeAction.PrereleaseToPrerelease] = "OrangeRed"; packageUpgradeActionPalette[PackageUpgradeAction.ReleaseToPrerelease] = "Firebrick"; packageUpgradeActionPalette[PackageUpgradeAction.Unknown] = "DarkGray"; var packageUpgradePalette = new PackageUpgradePalette(packageUpgradeActionPalette) { MissingPackageColor = "Red", PrereleaseColor = "Gainsboro", }; var visualizer = new PackageUpgradeVisualizer(directedGraph, packageUpgradePalette); foreach (var recentPackage in packages) { var upgrades = await walker.GetPackageUpgradesAsync(recentPackage).ConfigureAwait(false); visualizer.Visualize(recentPackage, upgrades); } return(directedGraph); }
public void UsesUpgradeActionPaletteAsStrokeForLink() { var packageUpgradeActionPalette = new PackageUpgradeActionPalette(); const string expected = "myColor"; packageUpgradeActionPalette[PackageUpgradeAction.PrereleaseToRelease] = expected; var packageUpgradePalette = new PackageUpgradePalette(packageUpgradeActionPalette); var visualizer = new PackageUpgradeVisualizer(_directedGraph, packageUpgradePalette); var package = StubPackageFactory.CreatePackage("A", "1.0.0"); var packageUpgrade = new PackageUpgrade( StubPackageDependencyFactory.CreateExact("B", "1.0.0"), PackageUpgradeAction.PrereleaseToRelease, null); visualizer.Visualize(package, new[] { packageUpgrade, }); Assert.Equal(expected, _directedGraph.Links[0].Stroke); }
public Visualize() { _directedGraph = new DirectedGraph(); _visualizer = new PackageUpgradeVisualizer(_directedGraph); }
public Visualize() { _directedGraph = new DirectedGraph(); _visualizer = new PackageUpgradeVisualizer(_directedGraph); }
public void UsesUpgradeActionPaletteAsStrokeForLink() { var packageUpgradeActionPalette = new PackageUpgradeActionPalette(); const string expected = "myColor"; packageUpgradeActionPalette[PackageUpgradeAction.PrereleaseToRelease] = expected; var packageUpgradePalette = new PackageUpgradePalette(packageUpgradeActionPalette); var visualizer = new PackageUpgradeVisualizer(_directedGraph, packageUpgradePalette); var package = StubPackageFactory.CreatePackage("A", "1.0.0"); var packageUpgrade = new PackageUpgrade( StubPackageDependencyFactory.CreateExact("B", "1.0.0"), PackageUpgradeAction.PrereleaseToRelease, null); visualizer.Visualize(package, new[] { packageUpgrade, }); Assert.Equal(expected, _directedGraph.Links[0].Stroke); }
public void UsesMissingPackageColorOfPaletteAsStrokeForNodeOfPackageDependency() { var packageUpgradePalette = new PackageUpgradePalette(); const string expected = "myColor"; packageUpgradePalette.MissingPackageColor = expected; var visualizer = new PackageUpgradeVisualizer(_directedGraph, packageUpgradePalette); var package = CreatePackage(); var packageUpgrade = CreatePackageUpgradeWithoutPackage(); visualizer.Visualize(package, new[] { packageUpgrade, }); var node = _directedGraph.Nodes[1]; Assert.Equal(expected, node.Stroke); }
public void UsesPrereleaseColorOfPaletteAsBackgroundForNodeOfPrereleasePackage() { var packageUpgradePalette = new PackageUpgradePalette(); const string expected = "myColor"; packageUpgradePalette.PrereleaseColor = expected; var visualizer = new PackageUpgradeVisualizer(_directedGraph, packageUpgradePalette); var package = StubPackageFactory.CreatePackage("A", "1.0.0-a"); visualizer.Visualize(package, Enumerable.Empty<PackageUpgrade>()); Assert.Equal(expected, _directedGraph.Nodes[0].Background); }
/// <summary> /// Visualizes the upgradeable dependencies of the specified packages. /// </summary> /// <param name="packages">The packages.</param> /// <param name="packageRepository">The repository to resolve package dependencies.</param> /// <param name="targetFramework">The framework to find compatible package dependencies.</param> /// <returns>The graph of the upgradeable dependencies of the specified packages.</returns> /// <exception cref="ArgumentNullException"><paramref name="packages"/> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="packageRepository"/> is <c>null</c>.</exception> /// <seealso cref="UpgradeWalker"/> /// <seealso cref="PackageUpgradeVisualizer"/> /// <remarks> /// The method estimates the impact of an upgrade action. The palette ranges from green to red indicating the risk of an upgrade action. /// <list type="table"> /// <listheader> /// <term><see cref="PackageUpgradeAction"/></term> /// <term>Color</term> /// <term>Risk</term> /// </listheader> /// <item> /// <term><see cref="PackageUpgradeAction.None"/></term> /// <term>Black</term> /// <term>0</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.MinVersion"/></term> /// <term>ForestGreen</term> /// <term>1</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.ReleaseToRelease"/></term> /// <term>Goldenrod</term> /// <term>2</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.PrereleaseToRelease"/></term> /// <term>DarkOrange</term> /// <term>3</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.PrereleaseToPrerelease"/></term> /// <term>OrangeRed</term> /// <term>4</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.ReleaseToPrerelease"/></term> /// <term>Firebrick</term> /// <term>5</term> /// </item> /// <item> /// <term><see cref="PackageUpgradeAction.Unknown"/></term> /// <term>DarkGray</term> /// <term>-</term> /// </item> /// </list> /// </remarks> public static DirectedGraph VisualizeUpgradeableDependencies( this IEnumerable<IPackage> packages, IPackageRepository packageRepository, FrameworkName targetFramework) { if (packages == null) { throw new ArgumentNullException(nameof(packages)); } if (packageRepository == null) { throw new ArgumentNullException(nameof(packageRepository)); } var walker = new UpgradeWalker(packageRepository, targetFramework); var directedGraphFactory = new DirectedGraphFactory(); var directedGraph = directedGraphFactory.CreateDependencyGraph(); var packageUpgradeActionPalette = new PackageUpgradeActionPalette(); packageUpgradeActionPalette[PackageUpgradeAction.None] = "Black"; packageUpgradeActionPalette[PackageUpgradeAction.MinVersion] = "ForestGreen"; packageUpgradeActionPalette[PackageUpgradeAction.ReleaseToRelease] = "Goldenrod"; packageUpgradeActionPalette[PackageUpgradeAction.PrereleaseToRelease] = "DarkOrange"; packageUpgradeActionPalette[PackageUpgradeAction.PrereleaseToPrerelease] = "OrangeRed"; packageUpgradeActionPalette[PackageUpgradeAction.ReleaseToPrerelease] = "Firebrick"; packageUpgradeActionPalette[PackageUpgradeAction.Unknown] = "DarkGray"; var packageUpgradePalette = new PackageUpgradePalette(packageUpgradeActionPalette); packageUpgradePalette.MissingPackageColor = "Red"; packageUpgradePalette.PrereleaseColor = "Gainsboro"; var visualizer = new PackageUpgradeVisualizer(directedGraph, packageUpgradePalette); foreach (var recentPackage in packages) { var upgrades = walker.GetPackageUpgrades(recentPackage); visualizer.Visualize(recentPackage, upgrades); } return directedGraph; }