public void ValidateKojtoCadVersionObject(int major, int minor, int buildNumber, int revisionNumber, bool result) { var version = new KojtoCadVersion { Major = major, Year = minor, ElapsedDays = buildNumber, Revision = revisionNumber }; var res = _validator.IsValid(version); Assert.Equal(result, res); }
public KojtoCadVersion GetLastReleasedVersion(KojtoCadVersion currentVersion) { if (!_versionValidator.IsValid(currentVersion)) { throw new ArgumentException(nameof(currentVersion)); } var availableVersions = _packageRepository.GetAvailablePackageVersions(); var latest = availableVersions.OrderBy(x => x.Major) .ThenBy(x => x.Year) .ThenBy(x => x.ElapsedDays) .ThenBy(x => x.Revision) .LastOrDefault(); return(latest); }
public KojtoCadVersion GetVersionFromText(string versionText) { if (!_versionValidator.IsValid(versionText)) { throw new ArgumentException(nameof(versionText)); } // old // KojtoCAD2013.1.0.0.0 // 2016.08.10.3 // new // 1.2017.365.3 var split = versionText.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries); var major = int.Parse(split[0]); var year = int.Parse(split[1]); var elapsedDays = int.Parse(split[2]); var revision = int.Parse(split[3]); var version = new KojtoCadVersion { Revision = revision, ElapsedDays = elapsedDays, Year = year, Major = major }; return(version); }