From 93f917aa0f1d1d6c2641851ed0b9eacf0dc75ada Mon Sep 17 00:00:00 2001 From: erri120 Date: Tue, 18 Aug 2020 10:48:22 +0200 Subject: [PATCH] Updated tests --- Extensions.Test/ExtensionUpdaterTest.cs | 55 +++++++++++++++++++++++++ Extensions.Test/Extensions.Test.csproj | 4 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Extensions.Test/ExtensionUpdaterTest.cs diff --git a/Extensions.Test/ExtensionUpdaterTest.cs b/Extensions.Test/ExtensionUpdaterTest.cs new file mode 100644 index 0000000..f5258d5 --- /dev/null +++ b/Extensions.Test/ExtensionUpdaterTest.cs @@ -0,0 +1,55 @@ +// /* +// Copyright (C) 2020 erri120 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// */ + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using ExtensionUpdater; +using Xunit; + +namespace Extensions.Test +{ + public class ExtensionUpdaterTest + { + [Fact] + public async Task TestGetGitHubReleases() + { + List releases = await GitHub.GetGitHubReleases("erri120/Playnite.Extensions"); + Assert.NotNull(releases); + Assert.NotEmpty(releases); + + var release = releases.First(); + Assert.NotNull(release.assets); + Assert.NotEmpty(release.assets); + + var asset = release.assets.OrderBy(x => x.size).First(); + Assert.NotNull(asset); + Assert.NotNull(asset.name); + Assert.NotNull(asset.browser_download_url); + + if(File.Exists(asset.name)) + File.Delete(asset.name); + + await GitHub.DownloadGitHubReleaseAsset(asset, asset.name); + Assert.True(File.Exists(asset.name)); + + var fsi = new FileInfo(asset.name); + Assert.Equal(asset.size, fsi.Length); + } + } +} \ No newline at end of file diff --git a/Extensions.Test/Extensions.Test.csproj b/Extensions.Test/Extensions.Test.csproj index 74b50f9..b11afcb 100644 --- a/Extensions.Test/Extensions.Test.csproj +++ b/Extensions.Test/Extensions.Test.csproj @@ -9,8 +9,9 @@ + - + @@ -18,6 +19,7 @@ +