Exemple #1
0
        public void TestUpdateDetectionProperties()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            var lastChecked       = checker.LastChecked;
            var originalUpdateUrl = checker.UpdateUrl;
            var originalUpdate    = checker.Update;

            Assert.DoesNotThrow(() =>
            {
                checker.MonitorForUpdates(
                    "v1",
                    null,
                    Timeout.Infinite
                    );
            });

            while (lastChecked == checker.LastChecked)
            {
                Thread.Sleep(500);
            }

            Assert.IsTrue(checker.UpdateAvailable);
            Assert.IsNotEmpty(checker.UpdateUrl);
            Assert.AreNotEqual(checker.UpdateUrl, originalUpdateUrl);
            Assert.IsNotNull(checker.Update);
            Assert.AreNotEqual(checker.Update, originalUpdate);
        }
Exemple #2
0
        public async Task TestEmptyGetRelease()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);
            var latest  = await checker.GetReleaseAsync();

            Assert.IsNotNull(latest);
        }
Exemple #3
0
        public void TestCheckerConstruction()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            Assert.AreEqual(checker.AccountName, account.Name);
            Assert.AreEqual(checker.Repository, account.Repository);
        }
Exemple #4
0
        public void ValidateApiUrlSpecificRelease()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            var url = checker.GetReleaseApiUrl(account.Release);

            Assert.AreEqual(url, "https://api.github.com/repos/nachmore/AmazonChimeHelper/releases/23205966");
        }
Exemple #5
0
        public void TestNullAccount()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            Assert.IsNull(checker.AccountName);
            Assert.IsNotNull(checker.Repository);

            Assert.ThrowsAsync <System.Net.Http.HttpRequestException>(() => checker.GetReleaseAsync());
        }
Exemple #6
0
        public async Task TestSpecificGetRelease()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);
            var release = await checker.GetReleaseAsync(account.Release);

            Assert.IsNotNull(release);
            Assert.IsFalse(release.PreRelease);
            Assert.AreEqual(release.Name, "Chime Helper 1.2");
            Assert.AreEqual(release.HtmlUrl, "https://github.com/nachmore/AmazonChimeHelper/releases/tag/v1.2");
            Assert.AreEqual(release.Assets.Length, 1);
            Assert.IsNotEmpty(release.ReleaseNotes);
        }
Exemple #7
0
        public void TestNullUpdateDetectionCallback()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            Assert.DoesNotThrow(() =>
            {
                checker.MonitorForUpdates(
                    "v1",
                    null,
                    Timeout.Infinite
                    );
            });
        }
Exemple #8
0
        public async Task TestMultipleAssets()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);
            var release = await checker.GetReleaseAsync(account.Release);

            Assert.IsNotNull(release);
            Assert.IsNotNull(release.Assets);

            Assert.AreEqual(release.Assets.Length, 4);

            var asset = release.Assets[2];

            Assert.AreEqual(asset.Name, "robo3t-1.4.0-windows-x86_64-12e54cc.exe");
            Assert.AreEqual(asset.Size, 19019000);
            Assert.AreEqual(asset.DownloadUrl, "https://github.com/Studio3T/robomongo/releases/download/v1.4.0/robo3t-1.4.0-windows-x86_64-12e54cc.exe");
        }
Exemple #9
0
        public void TestInvalidUpdateDetectionInterval()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            GitHubRelease latestRelease = null;

            Assert.Throws <ArgumentException>(() =>
            {
                checker.MonitorForUpdates(
                    "v1",
                    (release) => { latestRelease = release; },
                    0
                    );
            });
            Assert.IsNull(latestRelease);
        }
Exemple #10
0
        public void TestUpdateDetectionExceptions()
        {
            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            var thrown = false;

            checker.UnhandledException += (source, e) =>
            {
                thrown = true;

                Assert.IsInstanceOf <System.Net.Http.HttpRequestException>(e);
            };

            checker.MonitorForUpdates("bing bong", null, Timeout.Infinite);

            while (!thrown)
            {
                Thread.Sleep(500);
            }

            // if we fall through it means thet test passed (since it didn't timeout)!
        }
Exemple #11
0
        public void TestUpdateDetection()
        {
            string versionToCheckFor = "v1";

            var account = GitHubTestAccount.Get();
            var checker = new ReleaseChecker(account.Name, account.Repository);

            GitHubRelease latestRelease = null;

            checker.MonitorForUpdates(
                versionToCheckFor,
                (release) => { latestRelease = release; },
                Timeout.Infinite
                );

            while (latestRelease == null)
            {
                Thread.Sleep(500);
            }

            Assert.IsNotNull(latestRelease);
            Assert.AreNotEqual(latestRelease.Version, versionToCheckFor);
        }