Ejemplo n.º 1
0
        public void HighlightsNothingWhenVersionAreTheSame()
        {
            var service = new PackageVersionHighlighterService();
            var package = new Package("test.package", new("4.0.4"));

            package.LatestStableVersion = new("4.0.4");
            package.LatestVersion       = new("4.0.4");

            var highlightedStableVersion = service.HighlightLatestStableVersion(package);
            var highlightedLatestVersion = service.HighlightLatestVersion(package);

            Assert.Equal("4.0.4", highlightedStableVersion);
            Assert.Equal("4.0.4", highlightedLatestVersion);
        }
Ejemplo n.º 2
0
        public void HighlightsTheMajorPart()
        {
            var service = new PackageVersionHighlighterService();
            var package = new Package("test.package", new("1.0.1"));

            package.LatestStableVersion = new("2.0.0");
            package.LatestVersion       = new("2.0.0");

            var highlightedStableVersion = service.HighlightLatestStableVersion(package);
            var highlightedLatestVersion = service.HighlightLatestVersion(package);

            Assert.Equal("[red]2.0.0[/]", highlightedStableVersion);
            Assert.Equal("[red]2.0.0[/]", highlightedLatestVersion);
        }
Ejemplo n.º 3
0
        public void HighlightsThePrereleasePart()
        {
            var service = new PackageVersionHighlighterService();
            var package = new Package("test.package", new("1.0.1-rc1-final"));

            package.LatestStableVersion = new("1.0.1-rc2-final");
            package.LatestVersion       = new("1.0.1-rc2-final");

            var highlightedStableVersion = service.HighlightLatestStableVersion(package);
            var highlightedLatestVersion = service.HighlightLatestVersion(package);

            Assert.Equal("1.0.1[green]-rc2-final[/]", highlightedStableVersion);
            Assert.Equal("1.0.1[green]-rc2-final[/]", highlightedLatestVersion);
        }
Ejemplo n.º 4
0
        public void HighlightsThePatchPart()
        {
            var service = new PackageVersionHighlighterService();
            var package = new Package("test.package", new("1.0.1"));

            package.LatestStableVersion = new("1.0.2");
            package.LatestVersion       = new("1.0.2");

            var highlightedStableVersion = service.HighlightLatestStableVersion(package);
            var highlightedLatestVersion = service.HighlightLatestVersion(package);

            Assert.Equal("1.0.[green]2[/]", highlightedStableVersion);
            Assert.Equal("1.0.[green]2[/]", highlightedLatestVersion);
        }
Ejemplo n.º 5
0
        public void HighlightsGreenWhenOlderVersionIsPrelease()
        {
            var service = new PackageVersionHighlighterService();
            var package = new Package("test.package", new("5.0.0-rc.2.20475.5"));

            package.LatestStableVersion = new("5.0.0");
            package.LatestVersion       = new("6.0.0-preview.2.21154.6");

            var highlightedStableVersion = service.HighlightLatestStableVersion(package);
            var highlightedLatestVersion = service.HighlightLatestVersion(package);

            Assert.Equal("[green]5.0.0[/]", highlightedStableVersion);
            Assert.Equal("[red]6.0.0-preview.2.21154.6[/]", highlightedLatestVersion);
        }
Ejemplo n.º 6
0
        public void HighlightsTheMajorPartWhenCurrentVersionIsHigherThanStableVersion()
        {
            var service = new PackageVersionHighlighterService();
            var package = new Package("test.package", new("6.0.0-preview.2.21154.6"));

            package.LatestStableVersion = new("5.0.5");
            package.LatestVersion       = new("6.0.0-preview.2.21154.6");

            var highlightedStableVersion = service.HighlightLatestStableVersion(package);
            var highlightedLatestVersion = service.HighlightLatestVersion(package);

            Assert.Equal("[red]5.0.5[/]", highlightedStableVersion);
            Assert.Equal("6.0.0-preview.2.21154.6", highlightedLatestVersion);
        }
Ejemplo n.º 7
0
        private void PrintResult()
        {
            var service = new PackageVersionHighlighterService();
            var table   = new Table();

            table.AddColumn("Package Name");
            table.AddColumn("Current Version");
            table.AddColumn("Latest Stable Version");
            table.AddColumn("Latest Version");

            foreach (Package p in _packages)
            {
                table.AddRow(
                    p.PackageName,
                    p.CurrentVersion.ToString(),
                    service.HighlightLatestStableVersion(p),
                    service.HighlightLatestVersion(p)
                    );
            }

            table.Columns[1].RightAligned();
            table.Columns[2].RightAligned();
            table.Columns[3].RightAligned();

            AnsiConsole.Write(table);

            Console.WriteLine();
            AnsiConsole.MarkupLine(
                "[dim]INFO:[/] Run [blue]packcheck upgrade[/] to upgrade the .csproj file with the latest stable versions.");
            AnsiConsole.MarkupLine(
                "[dim]INFO:[/] Run [blue]packcheck upgrade --version latest[/] to upgrade the .csproj file with the latest versions.");
            AnsiConsole.MarkupLine(
                "[dim]INFO:[/] Run [blue]packcheck upgrade <Package Name>[/] to upgrade only the specified package to the latest stable version.");
            AnsiConsole.MarkupLine(
                "[dim]INFO:[/] Run [blue]packcheck upgrade <Package Name> --version latest[/] to upgrade only the specified package to the latest version.");
            Console.WriteLine();
        }