public void parsing_valid_release(string tag) { ReleaseTagVersion t = ReleaseTagVersion.TryParse(tag); Assert.That(t.IsValid); Assert.That(t.IsPreRelease, Is.False); Assert.That(t.IsPreReleasePatch, Is.False); Assert.That(t.ToString(ReleaseTagFormat.SemVer), Is.EqualTo(tag)); Assert.That(t.ToString(ReleaseTagFormat.NuGetPackage), Is.EqualTo(tag)); }
public void pre_release_with_standard_names_nugetV2_mappings(string tag, string nuget) { ReleaseTagVersion t = ReleaseTagVersion.TryParse(tag); Assert.That(t.IsValid); Assert.That(t.IsPreRelease); Assert.That(t.IsPreReleaseNameStandard); Assert.That(t.IsPreReleasePatch, Is.False); Assert.That(t.ToString(ReleaseTagFormat.SemVer), Is.EqualTo(tag)); Assert.That(t.ToString(ReleaseTagFormat.NuGetPackage), Is.EqualTo(nuget)); Assert.That(SemVersion.Parse(nuget).Prerelease.Length, Is.LessThanOrEqualTo(20)); }
public void to_string_pre_release_with_nonstandard_names_works_for_SemVer_but_throws_for_NuGetV2(string tag) { ReleaseTagVersion t = ReleaseTagVersion.TryParse(tag); Assert.That(t.IsValid); Assert.That(t.IsPreRelease); Assert.That(!t.IsPreReleaseNameStandard); Assert.That(t.IsPreReleasePatch); Assert.That(t.PreReleasePatch, Is.GreaterThan(0)); Assert.That(t.ToString(ReleaseTagFormat.SemVer, null, true), Is.EqualTo(tag)); Assert.Throws <ArgumentException>(() => t.ToString(ReleaseTagFormat.NugetPackageV2, null, true)); }
static void DumpVersionInfo( CIBuildDescriptor buildInfo, ReleaseTagVersion t ) { var nugetV2Build = t.ToString( ReleaseTagFormat.NugetPackageV2, buildInfo ); int nugetV2BuildSNLen = SemVersion.Parse( nugetV2Build ).Prerelease.Length; Console.WriteLine( "{0}, CI = {1}, NuGet = {2}, NuGet CI = {3}, NugetV2Build.SpecialName.Length = {4}", t, t.ToString( ReleaseTagFormat.SemVer, buildInfo ), t.ToString( ReleaseTagFormat.NugetPackageV2 ), nugetV2Build, nugetV2BuildSNLen ); Assert.That( nugetV2BuildSNLen, Is.LessThanOrEqualTo( 20 ) ); }
public void CIBuildVersion_LastReleaseBased_are_correctely_ordered( string tag ) { ReleaseTagFormat formatV2 = ReleaseTagFormat.NugetPackageV2; var t = ReleaseTagVersion.TryParse( tag ); var v = SemVersion.Parse( t.ToString( ReleaseTagFormat.SemVer ), true ); var tNext = new ReleaseTagVersion( t.OrderedVersion + 1 ); var vNext = SemVersion.Parse( tNext.ToString( ReleaseTagFormat.SemVer ), true ); var tPrev = new ReleaseTagVersion( t.OrderedVersion - 1 ); var vPrev = SemVersion.Parse( tPrev.ToString( ReleaseTagFormat.SemVer ), true ); Assert.That( vPrev < v, "{0} < {1}", vPrev, v ); Assert.That( v < vNext, "{0} < {1}", v, vNext ); var sNuGet = t.ToString( formatV2 ); var sNuGetPrev = tPrev.ToString( formatV2 ); var sNuGetNext = tNext.ToString( formatV2 ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGetPrev, sNuGet ) < 0, "{0} < {1}", sNuGetPrev, sNuGet ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGet, sNuGetNext ) < 0, "{0} < {1}", sNuGet, sNuGetNext ); CIBuildDescriptor ci = new CIBuildDescriptor { BranchName = "dev", BuildIndex = 1 }; string sCI = t.ToString( ReleaseTagFormat.SemVer, ci ); SemVersion vCi = SemVersion.Parse( sCI, true ); Assert.That( v < vCi, "{0} < {1}", v, vCi ); Assert.That( vCi < vNext, "{0} < {1}", vCi, vNext ); var sNuGetCI = t.ToString( formatV2, ci ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGet, sNuGetCI ) < 0, "{0} < {1}", sNuGet, sNuGetCI ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGetCI, sNuGetNext ) < 0, "{0} < {1}", sNuGetCI, sNuGetNext ); string sCiNext = tNext.ToString( ReleaseTagFormat.SemVer, ci ); SemVersion vCiNext = SemVersion.Parse( sCiNext, true ); Assert.That( vCiNext > vCi, "{0} > {1}", vCiNext, vCi ); Assert.That( vCiNext > vNext, "{0} > {1}", vCiNext, vNext ); var sNuGetCINext = tNext.ToString( formatV2, ci ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGetCINext, sNuGetCI ) > 0, "{0} > {1}", sNuGetCINext, sNuGetCI ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGetCINext, sNuGetNext ) > 0, "{0} > {1}", sNuGetCINext, sNuGetNext ); string sCiPrev = tPrev.ToString( ReleaseTagFormat.SemVer, ci ); SemVersion vCiPrev = SemVersion.Parse( sCiPrev, true ); Assert.That( vCiPrev > vPrev, "{0} > {1}", vCiPrev, vPrev ); Assert.That( vCiPrev < v, "{0} < {1}", vCiPrev, v ); Assert.That( vCiPrev < vCiNext, "{0} < {1}", vCiPrev, vCiNext ); var sNuGetCIPrev = tPrev.ToString( formatV2, ci ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGetCIPrev, sNuGetPrev ) > 0, "{0} > {1}", sNuGetCIPrev, sNuGetPrev ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGetCIPrev, sNuGet ) < 0, "{0} < {1}", sNuGetCIPrev, sNuGet ); Assert.That( NuGetV2StringComparer.DefaultComparer.Compare( sNuGetCIPrev, sNuGetCINext ) < 0, "{0} < {1}", sNuGetCIPrev, sNuGetCINext ); }
static void DumpVersionInfo(CIBuildDescriptor buildInfo, ReleaseTagVersion t) { var nugetV2Build = t.ToString(ReleaseTagFormat.NugetPackageV2, buildInfo); int nugetV2BuildSNLen = SemVersion.Parse(nugetV2Build).Prerelease.Length; Console.WriteLine("{0}, CI = {1}, NuGet = {2}, NuGet CI = {3}, NugetV2Build.SpecialName.Length = {4}", t, t.ToString(ReleaseTagFormat.SemVer, buildInfo), t.ToString(ReleaseTagFormat.NugetPackageV2), nugetV2Build, nugetV2BuildSNLen ); Assert.That(nugetV2BuildSNLen, Is.LessThanOrEqualTo(20)); }
//static int _greatersuccessorCount = 0; ReleaseTagVersion CheckMapping(long v) { if (v < 0 || v > ReleaseTagVersion.VeryLastVersion.OrderedVersion) { Assert.Throws <ArgumentException>(() => new ReleaseTagVersion(v)); return(null); } var t = new ReleaseTagVersion(v); Assert.That((v == 0) == !t.IsValid); Assert.That(t.OrderedVersion, Is.EqualTo(v)); var sSemVer = t.ToString(ReleaseTagFormat.SemVer); var tSemVer = ReleaseTagVersion.TryParse(sSemVer); var tNormalized = ReleaseTagVersion.TryParse(t.ToString(ReleaseTagFormat.Normalized)); Assert.That(tSemVer.OrderedVersion, Is.EqualTo(v)); Assert.That(tNormalized.OrderedVersion, Is.EqualTo(v)); Assert.That(tNormalized.Equals(t)); Assert.That(tSemVer.Equals(t)); Assert.That(tNormalized.Equals((object)t)); Assert.That(tSemVer.Equals((object)t)); Assert.That(tNormalized.CompareTo(t) == 0); Assert.That(tSemVer == t); Assert.That(tSemVer.ToString(), Is.EqualTo(t.ToString())); Assert.That(tNormalized.ToString(), Is.EqualTo(t.ToString())); // Successors/Predecessors check. var vSemVer = SemVersion.Parse(sSemVer, true); int count = 0; foreach (var succ in t.GetDirectSuccessors(false)) { ++count; Assert.That(succ.IsDirectPredecessor(t)); var vSemVerSucc = SemVersion.Parse(succ.ToString(ReleaseTagFormat.SemVer)); Assert.That(vSemVer < vSemVerSucc, "{0} < {1}", vSemVer, vSemVerSucc); } //if( count > _greatersuccessorCount ) //{ // Console.WriteLine( " -> - found {0} successors for '{1}':", count, t ); // Console.WriteLine( " " + string.Join( ", ", t.GetDirectSuccessors( false ).Select( s => s.ToString() ) ) ); // var closest = t.GetDirectSuccessors( true ).Select( s => s.ToString() ).ToList(); // Console.WriteLine( " - {0} closest successors:", closest.Count, t ); // Console.WriteLine( " " + string.Join( ", ", closest ) ); // _greatersuccessorCount = count; //} return(t); }
public void display_versions_and_CI_version(string version, string after) { var buildInfo = new CIBuildDescriptor() { BranchName = "develop", BuildIndex = 15 }; ReleaseTagVersion v = ReleaseTagVersion.TryParse(version); string vCI = v.ToString(ReleaseTagFormat.SemVer, buildInfo); ReleaseTagVersion vNext = new ReleaseTagVersion(v.OrderedVersion + 1); Console.WriteLine("Version = {0}, CI = {1}, Next = {2}", v, vCI, vNext); var vSemVer = SemVersion.Parse(v.ToString(ReleaseTagFormat.SemVer)); var vCISemVer = SemVersion.Parse(vCI); var vNextSemVer = SemVersion.Parse(vNext.ToString(ReleaseTagFormat.SemVer)); Assert.That(vSemVer < vCISemVer, "{0} < {1}", vSemVer, vCISemVer); Assert.That(vCISemVer < vNextSemVer, "{0} < {1}", vCISemVer, vNextSemVer); foreach (var vAfter in after.Split(',').Select(s => SemVersion.Parse(s.Trim()))) { Assert.That(vAfter.CompareTo(vCISemVer) > 0, "{0} > {1}", vAfter, vCISemVer); } }
public void display_name_and_successors_samples(string v) { ReleaseTagVersion t = ReleaseTagVersion.TryParse(v); var succ = t.GetDirectSuccessors(false); Console.WriteLine(" -> - found {0} successors for '{1}' (NuGetV2 = {2}, Ordered Version = {3}, File = {4}.{5}.{6}.{7}):", succ.Count(), t, t.ToString(ReleaseTagFormat.NugetPackageV2), t.OrderedVersion, t.OrderedVersionMajor, t.OrderedVersionMinor, t.OrderedVersionBuild, t.OrderedVersionRevision ); Console.WriteLine(" " + string.Join(", ", succ.Select(s => s.ToString()))); }
public void checking_extreme_version_ordering(string tag, bool atEnd, int expectedRank) { var t = ReleaseTagVersion.TryParse(tag); if (atEnd) { Assert.That(t.OrderedVersion - (ReleaseTagVersion.VeryLastVersion.OrderedVersion - expectedRank), Is.EqualTo(0)); } else { Assert.That(t.OrderedVersion - (ReleaseTagVersion.VeryFirstVersion.OrderedVersion + expectedRank), Is.EqualTo(0)); } var t2 = new ReleaseTagVersion(t.OrderedVersion); Assert.That(t2.ToString(), Is.EqualTo(t.ToString())); Assert.That(t.Equals(t2)); }
public void display_versions_and_CI_version( string version, string after ) { var buildInfo = new CIBuildDescriptor() { BranchName = "develop", BuildIndex = 15 }; ReleaseTagVersion v = ReleaseTagVersion.TryParse( version ); string vCI = v.ToString( ReleaseTagFormat.SemVer, buildInfo ); ReleaseTagVersion vNext = new ReleaseTagVersion( v.OrderedVersion + 1 ); Console.WriteLine( "Version = {0}, CI = {1}, Next = {2}", v, vCI, vNext ); var vSemVer = SemVersion.Parse( v.ToString( ReleaseTagFormat.SemVer ) ); var vCISemVer = SemVersion.Parse( vCI ); var vNextSemVer = SemVersion.Parse( vNext.ToString( ReleaseTagFormat.SemVer ) ); Assert.That( vSemVer < vCISemVer, "{0} < {1}", vSemVer, vCISemVer ); Assert.That( vCISemVer < vNextSemVer, "{0} < {1}", vCISemVer, vNextSemVer ); foreach( var vAfter in after.Split( ',' ).Select( s => SemVersion.Parse( s.Trim() )) ) { Assert.That( vAfter.CompareTo( vCISemVer ) > 0, "{0} > {1}", vAfter, vCISemVer ); } }
//static int _greatersuccessorCount = 0; ReleaseTagVersion CheckMapping( long v ) { if( v < 0 || v > ReleaseTagVersion.VeryLastVersion.OrderedVersion ) { Assert.Throws<ArgumentException>( () => new ReleaseTagVersion( v ) ); return null; } var t = new ReleaseTagVersion( v ); Assert.That( (v == 0) == !t.IsValid ); Assert.That( t.OrderedVersion, Is.EqualTo( v ) ); var sSemVer = t.ToString( ReleaseTagFormat.SemVer ); var tSemVer = ReleaseTagVersion.TryParse( sSemVer ); var tNormalized = ReleaseTagVersion.TryParse( t.ToString( ReleaseTagFormat.Normalized ) ); Assert.That( tSemVer.OrderedVersion, Is.EqualTo( v ) ); Assert.That( tNormalized.OrderedVersion, Is.EqualTo( v ) ); Assert.That( tNormalized.Equals( t ) ); Assert.That( tSemVer.Equals( t ) ); Assert.That( tNormalized.Equals( (object)t ) ); Assert.That( tSemVer.Equals( (object)t ) ); Assert.That( tNormalized.CompareTo( t ) == 0 ); Assert.That( tSemVer == t ); Assert.That( tSemVer.ToString(), Is.EqualTo( t.ToString() ) ); Assert.That( tNormalized.ToString(), Is.EqualTo( t.ToString() ) ); // Successors/Predecessors check. var vSemVer = SemVersion.Parse( sSemVer, true ); int count = 0; foreach( var succ in t.GetDirectSuccessors( false ) ) { ++count; Assert.That( succ.IsDirectPredecessor( t ) ); var vSemVerSucc = SemVersion.Parse( succ.ToString( ReleaseTagFormat.SemVer ) ); Assert.That( vSemVer < vSemVerSucc, "{0} < {1}", vSemVer, vSemVerSucc ); } //if( count > _greatersuccessorCount ) //{ // Console.WriteLine( " -> - found {0} successors for '{1}':", count, t ); // Console.WriteLine( " " + string.Join( ", ", t.GetDirectSuccessors( false ).Select( s => s.ToString() ) ) ); // var closest = t.GetDirectSuccessors( true ).Select( s => s.ToString() ).ToList(); // Console.WriteLine( " - {0} closest successors:", closest.Count, t ); // Console.WriteLine( " " + string.Join( ", ", closest ) ); // _greatersuccessorCount = count; //} return t; }
public void checking_extreme_version_ordering( string tag, bool atEnd, int expectedRank ) { var t = ReleaseTagVersion.TryParse( tag ); if( atEnd ) { Assert.That( t.OrderedVersion - (ReleaseTagVersion.VeryLastVersion.OrderedVersion - expectedRank), Is.EqualTo( 0 ) ); } else { Assert.That( t.OrderedVersion - (ReleaseTagVersion.VeryFirstVersion.OrderedVersion + expectedRank), Is.EqualTo( 0 ) ); } var t2 = new ReleaseTagVersion( t.OrderedVersion ); Assert.That( t2.ToString(), Is.EqualTo( t.ToString() ) ); Assert.That( t.Equals( t2 ) ); }
public void CIBuildVersion_LastReleaseBased_are_correctely_ordered(string tag) { ReleaseTagFormat formatV2 = ReleaseTagFormat.NugetPackageV2; var t = ReleaseTagVersion.TryParse(tag); var v = SemVersion.Parse(t.ToString(ReleaseTagFormat.SemVer), true); var tNext = new ReleaseTagVersion(t.OrderedVersion + 1); var vNext = SemVersion.Parse(tNext.ToString(ReleaseTagFormat.SemVer), true); var tPrev = new ReleaseTagVersion(t.OrderedVersion - 1); var vPrev = SemVersion.Parse(tPrev.ToString(ReleaseTagFormat.SemVer), true); Assert.That(vPrev < v, "{0} < {1}", vPrev, v); Assert.That(v < vNext, "{0} < {1}", v, vNext); var sNuGet = t.ToString(formatV2); var sNuGetPrev = tPrev.ToString(formatV2); var sNuGetNext = tNext.ToString(formatV2); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetPrev, sNuGet) < 0, "{0} < {1}", sNuGetPrev, sNuGet); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGet, sNuGetNext) < 0, "{0} < {1}", sNuGet, sNuGetNext); CIBuildDescriptor ci = new CIBuildDescriptor { BranchName = "dev", BuildIndex = 1 }; string sCI = t.ToString(ReleaseTagFormat.SemVer, ci); SemVersion vCi = SemVersion.Parse(sCI, true); Assert.That(v < vCi, "{0} < {1}", v, vCi); Assert.That(vCi < vNext, "{0} < {1}", vCi, vNext); var sNuGetCI = t.ToString(formatV2, ci); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGet, sNuGetCI) < 0, "{0} < {1}", sNuGet, sNuGetCI); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCI, sNuGetNext) < 0, "{0} < {1}", sNuGetCI, sNuGetNext); string sCiNext = tNext.ToString(ReleaseTagFormat.SemVer, ci); SemVersion vCiNext = SemVersion.Parse(sCiNext, true); Assert.That(vCiNext > vCi, "{0} > {1}", vCiNext, vCi); Assert.That(vCiNext > vNext, "{0} > {1}", vCiNext, vNext); var sNuGetCINext = tNext.ToString(formatV2, ci); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCINext, sNuGetCI) > 0, "{0} > {1}", sNuGetCINext, sNuGetCI); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCINext, sNuGetNext) > 0, "{0} > {1}", sNuGetCINext, sNuGetNext); string sCiPrev = tPrev.ToString(ReleaseTagFormat.SemVer, ci); SemVersion vCiPrev = SemVersion.Parse(sCiPrev, true); Assert.That(vCiPrev > vPrev, "{0} > {1}", vCiPrev, vPrev); Assert.That(vCiPrev < v, "{0} < {1}", vCiPrev, v); Assert.That(vCiPrev < vCiNext, "{0} < {1}", vCiPrev, vCiNext); var sNuGetCIPrev = tPrev.ToString(formatV2, ci); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCIPrev, sNuGetPrev) > 0, "{0} > {1}", sNuGetCIPrev, sNuGetPrev); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCIPrev, sNuGet) < 0, "{0} < {1}", sNuGetCIPrev, sNuGet); Assert.That(NuGetV2StringComparer.DefaultComparer.Compare(sNuGetCIPrev, sNuGetCINext) < 0, "{0} < {1}", sNuGetCIPrev, sNuGetCINext); }