diff --git a/app/src/androidTest/java/com/github/javiersantos/appupdater/LibraryTest.java b/app/src/androidTest/java/com/github/javiersantos/appupdater/LibraryTest.java index 5f5f17cb..a12c9616 100644 --- a/app/src/androidTest/java/com/github/javiersantos/appupdater/LibraryTest.java +++ b/app/src/androidTest/java/com/github/javiersantos/appupdater/LibraryTest.java @@ -45,6 +45,41 @@ public void Version_UpdateAvailable_3() { assertTrue(UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); } + @Test + public void Version_UpdateAvailable_4() { + Update installedUpdate = new Update(); + installedUpdate.setLatestVersion("2.1.3.alpha.42.RC"); + + Update latestUpdate = new Update(); + latestUpdate.setLatestVersion("2.1.3.alpha.45.RC"); + + assertTrue(UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); + } + + @Test + public void VersionCode_UpdateAvailable_1() { + Update installedUpdate = new Update("1.0.0", 1); + Update latestUpdate = new Update("1.0.0", 2); + + assertTrue(UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); + } + + @Test + public void VersionCode_UpdateAvailable_2() { + Update installedUpdate = new Update("1.0.0", 1); + Update latestUpdate = new Update("1.0.1", 2); + + assertTrue(UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); + } + + @Test + public void VersionCode_UpdateAvailable_3() { + Update installedUpdate = new Update("1.0.0", 1); + Update latestUpdate = new Update("0.9.0", 2); + + assertTrue(UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); + } + @Test public void Version_UpdateNotAvailable_1() { Update installedUpdate = new Update(); @@ -67,4 +102,28 @@ public void Version_UpdateNotAvailable_2() { assertTrue(!UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); } + @Test + public void VersionCode_UpdateNotAvailable_1() { + Update installedUpdate = new Update("1.0.0", 1); + Update latestUpdate = new Update("1.0.0", 1); + + assertTrue(!UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); + } + + @Test + public void VersionCode_UpdateNotAvailable_2() { + Update installedUpdate = new Update("1.0.0", 2); + Update latestUpdate = new Update("1.0.1", 1); + + assertTrue(!UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); + } + + @Test + public void VersionCode_UpdateNotAvailable_3() { + Update installedUpdate = new Update("1.0.0", 1); + Update latestUpdate = new Update("1.2.0", 1); + + assertTrue(!UtilsLibrary.isUpdateAvailable(installedUpdate, latestUpdate)); + } + }