public void TestExceedRemoteDepth() { // current release is 2.4.1.5 GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest"); // version must be same as obj (otherwise compare will stop before limit is reached) // this tests TesExceedEnumDepth at the same time (creating repo only for this test is too much overhead) Assert.IsFalse(obj.IsUpdateAvailable("2.4.1.5.10", (VersionChange)5)); }
public void TestUpdateMajorAvailable() { // current release is 2.4.1.5 // it is guarantees that those releases are not deleted // => every releaes can be used to check for updates GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest"); // it is guaranteed that this version will not change (2.4.1.5 Assert.IsTrue(obj.IsUpdateAvailable("1.0.0", VersionChange.Major)); // higher minor,... versions Assert.IsTrue(obj.IsUpdateAvailable("1.9.9", VersionChange.Major)); Assert.IsFalse(obj.IsUpdateAvailable("2.0.0", VersionChange.Major)); // equal version Assert.IsFalse(obj.IsUpdateAvailable("2.4.1.5", VersionChange.Major)); // newer local version Assert.IsFalse(obj.IsUpdateAvailable("3.0.0.0", VersionChange.Major)); }
public void TestValidVersionPattern() { // invalid repo will return false // this makes web request faster, as the request returns null without downloading resources GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "d5a4426e-8e8e-421e-b8d0-129e826153e3"); obj.IsUpdateAvailable("1.0.0.0"); obj.IsUpdateAvailable("1.0.0"); obj.IsUpdateAvailable("v.1.0.0.0"); obj.IsUpdateAvailable("v.1.0.0"); obj.IsUpdateAvailable("v1.0.0.0"); obj.IsUpdateAvailable("v1.0.0"); obj.IsUpdateAvailable("158.080.098900.55400"); obj.IsUpdateAvailable("v.0.054.4480.9499849840"); obj.IsUpdateAvailable("x1.0.0.0"); obj.IsUpdateAvailable("x.1.0.0"); }
public void TestUpdateBuildAvailable() { // current release is 2.4.1.5 // it is guarantees that those releases are not deleted // => every releaes can be used to check for updates GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest"); // it is guaranteed that this version will not change (2.4.1.5 Assert.IsTrue(obj.IsUpdateAvailable("2.4.0", VersionChange.Build)); // smaller minor and higher build version Assert.IsTrue(obj.IsUpdateAvailable("2.4.0.6", VersionChange.Build)); // euqal minor but smaller build Assert.IsFalse(obj.IsUpdateAvailable("2.4.1.0", VersionChange.Build)); // equal version Assert.IsFalse(obj.IsUpdateAvailable("2.4.1.5", VersionChange.Build)); // newer local version Assert.IsFalse(obj.IsUpdateAvailable("2.4.90.0", VersionChange.Build)); }
private void SendUpdateNotif() { if (Convert.ToBoolean(Config.AppSettings.Settings["passwordEnabled"].Value)) { var update = new GithubUpdateCheck("ahsan-a", "PhoneLink"); var isUpdate = update.IsUpdateAvailable(AppVersion, VersionChange.Minor); if (isUpdate) { SendNotification("PhoneLink Update Available", "Update to get the latest features. A new release is available on the Github repository. You can disable checking for releases in the PhoneLink menu."); } } }
private void CheckForUpdates() { try { var updateCheck = new GithubUpdateCheck("micah686", "VnManager"); bool updateAvailable = updateCheck.IsUpdateAvailable(App.VersionString, VersionChange.Build); if (updateAvailable == false) { return; } var result = _windowManager.ShowMessageBox(App.ResMan.GetString("UpdateMsg"), App.ResMan.GetString("UpdateAvailable"), MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { const int twoMegaBytes = 2000000; var releasePath = new Uri(@"https://github.com/micah686/VnManager/releases/latest/download/VnManagerInstaller.exe"); var tempFolder = Path.GetTempPath(); var filePath = $@"{tempFolder}VnManager-{Guid.NewGuid()}.exe"; using (var client = new WebClient()) { client.DownloadFile(releasePath, filePath); } var totalBytes = new FileInfo(filePath).Length; if (totalBytes > twoMegaBytes) { var ps = new ProcessStartInfo(filePath) { UseShellExecute = true, Verb = "open" }; Process.Start(ps); Environment.Exit(0); } } } catch (Exception e) { App.Logger.Warning(e, "Failed to check for Updates"); SentryHelper.SendException(e, null, SentryLevel.Warning); } }
private void TestInvalidVersionPattern_Wrapper(GithubUpdateCheck obj, string version) { Assert.ThrowsException <Mayerch1.GithubUpdateCheck.InvalidVersionException>(() => obj.IsUpdateAvailable(version)); }
public void TestNullPattern() { GithubUpdateCheck obj = new GithubUpdateCheck("", ""); Assert.ThrowsException <Mayerch1.GithubUpdateCheck.InvalidVersionException>(() => obj.IsUpdateAvailable(null)); }
public void TestInvalidRemoteVersionPattern() { GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest2"); Assert.ThrowsException <Mayerch1.GithubUpdateCheck.InvalidVersionException>(() => obj.IsUpdateAvailable("1.0.0")); }