Esempio n. 1
0
        public void ExtendedConverters()
        {
            // Verify that the extended type converters work.

            string value;

            //------------------------------------------------------------------

            var semanticVersion = SemanticVersion.Create(1, 2, 3, "build-0", "alpha");

            value = NeonHelper.JsonSerialize(semanticVersion);
            Assert.Equal(semanticVersion, NeonHelper.JsonDeserialize <SemanticVersion>(value));

            //------------------------------------------------------------------

            var timespan = TimeSpan.FromDays(2.1234567);

            value = NeonHelper.JsonSerialize(timespan);
            Assert.Equal(timespan, NeonHelper.JsonDeserialize <TimeSpan>(value));

            //------------------------------------------------------------------

            var version = new Version(1, 2, 3);

            value = NeonHelper.JsonSerialize(version);
            Assert.Equal(version, NeonHelper.JsonDeserialize <Version>(value));
        }
Esempio n. 2
0
        public async Task Version()
        {
            using (var runner = new ProgramRunner())
            {
                var result = await runner.ExecuteAsync(Program.Main, "tool", "version");

                Assert.Equal(0, result.ExitCode);
                Assert.Equal(KubeVersions.Kubernetes, result.OutputText.Trim());

                result = await runner.ExecuteAsync(Program.Main, "tool", "version", "-n");

                Assert.Equal(0, result.ExitCode);
                Assert.Equal(KubeVersions.Kubernetes, result.OutputText.Trim());
                Assert.DoesNotContain('\n', result.OutputText);

                result = await runner.ExecuteAsync(Program.Main, "tool", "version", "-n", "--git");

                Assert.Equal(0, result.ExitCode);
                Assert.Equal($"{KubeVersions.Kubernetes}/{ThisAssembly.Git.Branch}-{ThisAssembly.Git.Commit}", result.OutputText.Trim());
                Assert.DoesNotContain('\n', result.OutputText);

                result = await runner.ExecuteAsync(Program.Main, "tool", "version", $"--minimum={Program.Version}");

                Assert.Equal(0, result.ExitCode);

                result = await runner.ExecuteAsync(Program.Main, "tool", "version", $"--minimum=0");

                Assert.Equal(0, result.ExitCode);

                result = await runner.ExecuteAsync(Program.Main, "tool", "version", $"--minimum=64000.0.0");

                Assert.NotEqual(0, result.ExitCode);

                var curVersion   = SemanticVersion.Parse(Program.Version);
                var newerVersion = SemanticVersion.Create(curVersion.Major, curVersion.Minor, curVersion.Patch + 1, curVersion.Build, curVersion.Prerelease);

                Assert.True(newerVersion > curVersion);

                result = await runner.ExecuteAsync(Program.Main, "tool", "version", $"--minimum={newerVersion}");

                Assert.NotEqual(0, result.ExitCode);
            }
        }