public static void IncreaseVersion(SemanticVersionType increaseVersionType, char separator) { string[] parts = PlayerSettings.bundleVersion.Split(separator); int version = 1; int index = (int)increaseVersionType; if (index >= parts.Length) { string[] versions = new string[(index + 1) - parts.Length]; for (int i = 0; i < versions.Length; i++) { versions[i] = "0"; } ArrayUtility.AddRange(ref parts, versions); } else if (int.TryParse(parts[index], out version)) { version += 1; } for (int i = index + 1; i < parts.Length;) { ArrayUtility.RemoveAt(ref parts, i); } parts[index] = version.ToString(); PlayerSettings.bundleVersion = string.Join(separator.ToString(), parts); }
public void DifferentVersionTypesArentEqual(SemanticVersionType semVerType1, SemanticVersionType semVerType2, int expected) { var semVer1 = CreateZeroVersion(semVerType1); var semVer2 = CreateZeroVersion(semVerType2); var actual = semVer1.CompareTo(semVer2); Assert.Equal(expected, actual); }
public void SpecialTypeHashCodeVerification(SemanticVersionType semVerType, ushort major, ushort minor, ushort patch, string[] specialParts) { var semVer = new SemanticVersion(major, minor, patch, specialParts, semVerType); var expected = GetSemVerHashCode(semVer); var actual = semVer.GetHashCode(); Assert.Equal(expected, actual); }
public void BiggerAlphaNumericPreReleaseYieldsPositiveResult(SemanticVersionType semVerType) { var semVer1 = new SemanticVersion(1, 2, 3, new[] { "bb" }, semVerType); var semVer2 = new SemanticVersion(1, 2, 3, new[] { "aa" }, semVerType); const int expected = 1; var actual = semVer1.CompareTo(semVer2); Assert.Equal(expected, actual); }
private void OnGUI() { semanticVersionType = (SemanticVersionType)EditorGUILayout.EnumPopup("Version Type", semanticVersionType); separator = EditorGUILayout.TextField("Separator", separator.ToString())[0]; //GUILayout.Space(); if (GUILayout.Button("Update")) { Increase(); Close(); } }
public void SpecialVersionsGetsSetCorrectly(SemanticVersionType semanticVersionType, ushort major, ushort minor, ushort patch, string[] specialVersionParts) { var expectedSpecialVersion = string.Join(".", specialVersionParts); var expected = new VersionResult { Major = major, Minor = minor, Patch = patch, SemanticVersionType = semanticVersionType, SpecialVersion = expectedSpecialVersion }; var actual = new SemanticVersion(major, minor, patch, specialVersionParts, semanticVersionType); actual.AsSource().OfLikeness<VersionResult>().ShouldEqual(expected); }
public void SpecialVersionsDoesntAllowNullSpecialVersionParts(SemanticVersionType semVerType, ushort major, ushort minor, ushort patch) { Assert.Throws<ArgumentNullException>(() => new SemanticVersion(major, minor, patch, null, semVerType)); }
public void CanNotInstantiateWithSpecialVersionWithNormalType(SemanticVersionType semanticVersionType, ushort major, ushort minor, ushort patch, string[] specialVersionParts) { Assert.Throws<ArgumentOutOfRangeException>(() => new SemanticVersion(major, minor, patch, specialVersionParts, semanticVersionType)); }
public void CanInstantiateWithSpecialVersionWithNonNormalType(SemanticVersionType semanticVersionType, ushort major, ushort minor, ushort patch, string[] specialVersionParts) { Assert.DoesNotThrow(() => new SemanticVersion(major, minor, patch, specialVersionParts, semanticVersionType)); }
public void ToStringFormatsCorrectlyWithSpecialVersions(SemanticVersionType semVerType, ushort major, ushort minor, ushort patch, string[] specialVersions) { var semVer = new SemanticVersion(major, minor, patch, specialVersions, semVerType); var expected = FormatVersion(semVer); var actual = semVer.ToString(); Assert.Equal(expected, actual); }
public void ThrowsExceptionOnMalformedSpecialVersionParts(SemanticVersionType semanticVersionType, ushort major, ushort minor, ushort patch, string[] specialVersionParts) { const string malformedSpecialPart = ".,"; var versionParts = specialVersionParts.Concat(new[] {malformedSpecialPart}); Assert.Throws<ArgumentException>(() => new SemanticVersion(major, minor, patch, versionParts, semanticVersionType)); }
private SemanticVersion CreateZeroVersion(SemanticVersionType semVerType) { if (semVerType == SemanticVersionType.Normal) { return new SemanticVersion(0, 0, 0); } return new SemanticVersion(0, 0, 0, new[] { "0" }, semVerType); }