Example #1
0
        public void TestInvalidRepository()
        {
            // random uuid, high change for non-existent repo
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "cb91fb82-9621-479a-9c5a-23e565e6390d");

            obj.IsUpdateAvailable("1.0.0.0");
        }
Example #2
0
        public void TestNoRelease()
        {
            // this repo doesn't have releases
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "BunnyVisual");

            Assert.IsFalse(obj.IsUpdateAvailable("1.0.0.0"));
        }
Example #3
0
        public void TestInvalidUser()
        {
            // random uuid, high change for non-existent repo
            GithubUpdateCheck obj = new GithubUpdateCheck("5fe54fd3-2fd8-48ff-8f63-1b8575348b5f", "GithubUpdateCheck");

            obj.IsUpdateAvailable("1.0.0.0");
        }
Example #4
0
        public void TestNullConstructor()
        {
            // if the repo is invalid,
            GithubUpdateCheck obj = new GithubUpdateCheck(null, null);

            Assert.IsFalse(obj.IsUpdateAvailable("1.0.0"));
        }
        public void TestInvalidPattern()
        {
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest", CompareType.Boolean);

            // this is the only invalid input
            Assert.ThrowsException <InvalidVersionException>(() => obj.IsUpdateAvailable(null));
        }
Example #6
0
        public void TestEqualsMethodFalse()
        {
            GithubUpdateCheck aCmpType = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean);
            GithubUpdateCheck bCmpType = new GithubUpdateCheck("DIFFERENT", "GithubUpdateCheck", CompareType.Boolean);

            Assert.IsFalse(aCmpType.Equals(bCmpType));
        }
        public void TestNoUpdateAvailable()
        {
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest", CompareType.Boolean);

            // the repo is guaranteed to have this version as latest patch ("v.2.4.1.5")
            Assert.IsFalse(obj.IsUpdateAvailable("v.2.4.1.5"));
        }
Example #8
0
        public void TestDefaultConstructorIsIncremental()
        {
            // compare type is private, therefore use compare
            GithubUpdateCheck defaultCon = new GithubUpdateCheck("", "");

            Assert.AreEqual(defaultCon.CompareType, CompareType.Incremental);
        }
Example #9
0
        public void TestEqualsMethodTrue()
        {
            GithubUpdateCheck aCmpType = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Incremental);
            GithubUpdateCheck bCmpType = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Incremental);

            Assert.IsTrue(aCmpType.Equals(bCmpType));
        }
 public async Task TestInvalidAsyncPattern()
 {
     // it is enough to test if the fail-path is working in generall
     // detailed testing is done for the Sync. method, as both call the same function
     GithubUpdateCheck obj = new GithubUpdateCheck("", "");
     await obj.IsUpdateAvailableAsync("invalid1..0.0.00..");
 }
        public void TestInvalidVersionPattern()
        {
            // should throw before web request is made
            GithubUpdateCheck obj = new GithubUpdateCheck("", "");


            // invalid prefix
            TestInvalidVersionPattern_Wrapper(obj, "vv.1.0.0.0.0");
            TestInvalidVersionPattern_Wrapper(obj, "vv1.0.0.0.0");

            // not enough groups
            TestInvalidVersionPattern_Wrapper(obj, "");
            TestInvalidVersionPattern_Wrapper(obj, " ");
            TestInvalidVersionPattern_Wrapper(obj, null);

            // invalid character
            TestInvalidVersionPattern_Wrapper(obj, "1.a0.0.0.0");
            TestInvalidVersionPattern_Wrapper(obj, "1.0.0a.0.0");
            TestInvalidVersionPattern_Wrapper(obj, "1.a0.0.0.0a");

            // invalid ending
            TestInvalidVersionPattern_Wrapper(obj, "1.0.0.0.0.");
            TestInvalidVersionPattern_Wrapper(obj, "1.0.0.0.");
            TestInvalidVersionPattern_Wrapper(obj, "1.0.0.");

            // multiple/invalid seperatiors
            TestInvalidVersionPattern_Wrapper(obj, "v..1.0.0.");
            TestInvalidVersionPattern_Wrapper(obj, "1..0.0.");
            TestInvalidVersionPattern_Wrapper(obj, "1.0....0");
            TestInvalidVersionPattern_Wrapper(obj, "1.0,0.0");
            TestInvalidVersionPattern_Wrapper(obj, "1.0.0.0;");
        }
Example #12
0
        public async Task TestInvalidUserAsync()
        {
            // random uuid, high change for non-existent repo
            GithubUpdateCheck obj = new GithubUpdateCheck("5fe54fd3-2fd8-48ff-8f63-1b8575348b5f", "GithubUpdateCheck");

            Assert.IsFalse(await obj.IsUpdateAvailableAsync("1.0.0.0"));
        }
Example #13
0
        public async Task TestInvalidRepositoryAsync()
        {
            // random uuid, high change for non-existent repo
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "cb91fb82-9621-479a-9c5a-23e565e6390d");

            Assert.IsFalse(await obj.IsUpdateAvailableAsync("1.0.0.0"));
        }
        public void TestExceedLocalDepth()
        {
            // current release is 2.4.1.5
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest");

            // passed version must be same as obj's version (otherwise compare will stop before the limit is reached)
            Assert.IsFalse(obj.IsUpdateAvailable("2.4", VersionChange.Minor));
        }
        public void TestUpdateAvailable()
        {
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheckUnitTest", CompareType.Boolean);

            // the repo is guaranteed to have this version as latest patch ("v.2.4.1.5")
            // the slightest difference shall assume an update, the strings are not normalized
            Assert.IsTrue(obj.IsUpdateAvailable("2.4.1.5"));
        }
        public void TestExceedEnumDepth()
        {
            // 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)
            Assert.IsFalse(obj.IsUpdateAvailable("2.4.1.5.99.4.6", (VersionChange)7));
        }
Example #17
0
        public async Task TestAsyncRequest()
        {
            GithubUpdateCheck obj = new GithubUpdateCheck("Mayerch1", "TheDiscordSoundboard");

            // it cannot be guaranteed, that the major version of TDS will stay at 2
            // more specific compares cannot be made
            Assert.IsTrue(await obj.IsUpdateAvailableAsync("1.0.0", VersionChange.Major));
        }
        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));
        }
Example #19
0
        public void TestAreEqualTrue()
        {
            // only if all are the same, it should return true
            GithubUpdateCheck aCmpType = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean);
            GithubUpdateCheck bCmpType = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean);

            bool isEqual = (aCmpType == bCmpType);

            Assert.IsTrue(isEqual);
        }
Example #20
0
        public void TestAreNotEqualTrue()
        {
            // assuming == is working, it is enough to test a single !=, as it returns !(==)

            GithubUpdateCheck aCmpType = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean);
            GithubUpdateCheck bCmpType = new GithubUpdateCheck("DIFFERENT", "GithubUpdateCheck", CompareType.Boolean);

            bool isDifferent = (aCmpType != bCmpType);

            Assert.IsTrue(isDifferent);
        }
Example #21
0
 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.");
         }
     }
 }
        public void TestUpdateRevisionAvailable()
        {
            // 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.1.1", VersionChange.Revision));

            // equal version
            Assert.IsFalse(obj.IsUpdateAvailable("2.4.1.5", VersionChange.Revision));
            // newer local version
            Assert.IsFalse(obj.IsUpdateAvailable("2.4.1.99", VersionChange.Revision));
        }
Example #23
0
        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);
            }
        }
        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));
        }
Example #26
0
        public void TestAreEqualFalse()
        {
            // change one member at a time
            bool isEqual;

            GithubUpdateCheck aCmpType = new GithubUpdateCheck("Mayerch1", "DIFFERENT", CompareType.Incremental);
            GithubUpdateCheck bCmpType = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Incremental);

            isEqual = (aCmpType == bCmpType);
            Assert.IsFalse(isEqual);

            GithubUpdateCheck aAuthor = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean);
            GithubUpdateCheck bAuthor = new GithubUpdateCheck("DIFFERENT", "GithubUpdateCheck", CompareType.Boolean);

            isEqual = (aAuthor == bAuthor);
            Assert.IsFalse(isEqual);

            GithubUpdateCheck aRepo = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean);
            GithubUpdateCheck bRepo = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Incremental);

            isEqual = (aRepo == bRepo);
            Assert.IsFalse(isEqual);
        }
 private void TestInvalidVersionPattern_Wrapper(GithubUpdateCheck obj, string version)
 {
     Assert.ThrowsException <Mayerch1.GithubUpdateCheck.InvalidVersionException>(() => obj.IsUpdateAvailable(version));
 }
Example #28
0
        private static async Task <bool> checkVersion()
        {
            var updateChecker = new GithubUpdateCheck(Handle.author, Handle.repo);

            return(await updateChecker.IsUpdateAvailableAsync(Handle.version, Mayerch1.GithubUpdateCheck.VersionChange.Revision));
        }
        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"));
        }