Ejemplo n.º 1
0
        public async Task TestGetLatestRepoReleaseIsNotNull()
        {
            var api    = new GitHubApiServer(new HttpClient());
            var latest = await api.GetLatestRepoRelease("sobu86", "TempRepoForGitHubApiTest");

            // No releases are planned for sobu86.github.io
            Assert.IsNotNull(latest);
        }
Ejemplo n.º 2
0
        public async Task TestReleaseAsset()
        {
            var api    = new GitHubApiServer(new HttpClient());
            var latest = await api.GetLatestRepoRelease("sobu86", "TempRepoForGitHubApiTest");

            // No releases are planned for sobu86.github.io
            Assert.IsNotNull(latest.Assets[0].BrowserDownloadUrl);

            Console.WriteLine($"Asset URL - {latest.Assets[0].BrowserDownloadUrl}");
        }
Ejemplo n.º 3
0
        public async Task TestGetLatestRepoReleaseFields()
        {
            var api    = new GitHubApiServer(new HttpClient());
            var latest = await api.GetLatestRepoRelease("sobu86", "TempRepoForGitHubApiTest");

            // No releases are planned for sobu86.github.io
            Assert.IsNotNull(latest);
            Assert.IsTrue(latest.Id != 0);
            Assert.IsNotNull(latest.TagName);
            Assert.IsNotNull(latest.PublishedAt);
        }
Ejemplo n.º 4
0
        public async Task TestGetLatestRepoReleaseIsActuallyLatestInList()
        {
            var api    = new GitHubApiServer(new HttpClient());
            var latest = await api.GetLatestRepoRelease("sobu86", "TempRepoForGitHubApiTest");

            var releases = await api.GetRepoReleaseList("sobu86", "TempRepoForGitHubApiTest");

            DateTime latestInList = DateTime.MinValue;

            releases.ForEach(r => latestInList =
                                 (r.PublishedAt > latestInList) ? r.PublishedAt : latestInList);

            Assert.AreEqual(latestInList, latest.PublishedAt);

            Console.WriteLine($"latest release @ {latest.PublishedAt}");
        }
Ejemplo n.º 5
0
        public async Task TestInvalidRepoNameLatestReleaseThrowsException()
        {
            var api = new GitHubApiServer(new HttpClient());

            bool exception = false;

            try
            {
                await api.GetLatestRepoRelease("sobu86", "invalid_repo");
            }
            catch (Exception)
            {
                exception = true;
            }

            Assert.IsTrue(exception);
        }