public void TryGetInvalidVersion() { Version version; float prerelease; bool success = PackageManifestUpdater.TryGetVersionComponents("x.2.3", out version, out prerelease); Assert.IsFalse(success); Assert.IsNull(version); Assert.AreEqual(prerelease, float.NaN); // Setting arbitrary values to ensure the function modifies them appropriately. version = new Version(5, 6, 7); prerelease = 17f; success = PackageManifestUpdater.TryGetVersionComponents("1.2.3-v20200417.19", out version, out prerelease); Assert.IsFalse(success); Assert.IsNull(version); Assert.AreEqual(prerelease, float.NaN); // Setting arbitrary values to ensure the function modifies them appropriately. version = new Version(5, 6, 7); prerelease = 17f; success = PackageManifestUpdater.TryGetVersionComponents("", out version, out prerelease); Assert.IsFalse(success); Assert.IsNull(version); Assert.AreEqual(prerelease, float.NaN); }
public void TryGetValidVersion() { Version version; float prerelease; bool success = PackageManifestUpdater.TryGetVersionComponents("17.27.43", out version, out prerelease); Assert.IsTrue(success); Assert.AreEqual(version, new Version(17, 27, 43)); Assert.AreEqual(prerelease, 0f); success = PackageManifestUpdater.TryGetVersionComponents("0.9.1-20200131.12", out version, out prerelease); Assert.IsTrue(success); Assert.AreEqual(version, new Version(0, 9, 1)); Assert.AreEqual(prerelease, 20200131.12f); }