wabbajack/Wabbajack.Networking.NexusApi.Test/NexusApiTests.cs

44 lines
1.1 KiB
C#
Raw Permalink Normal View History

2021-09-27 12:42:46 +00:00
using System.Linq;
using System.Threading.Tasks;
using Xunit;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Networking.NexusApi.Test;
public class NexusApiTests
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
private readonly NexusApi _api;
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public NexusApiTests(NexusApi api)
{
_api = api;
}
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
[Fact]
public async Task CanValidateUser()
{
var (info, headers) = await _api.Validate();
Assert.True(info.IsPremium);
}
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
[Fact]
public async Task CanGetModInfo()
{
var (_, originalHeaders) = await _api.Validate();
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
var (info, headers) = await _api.ModInfo("skyrimspecialedition", 12604);
Assert.Equal("SkyUI", info.Name);
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
var (files, _) = await _api.ModFiles("skyrimspecialedition", 12604);
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
Assert.True(files.Files.Length > 0);
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
var (file, _) = await _api.FileInfo("skyrimspecialedition", 12604,
files.Files.OrderByDescending(f => f.FileId).First().FileId);
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
Assert.Equal("MAIN", file.CategoryName);
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
var (links, _) = await _api.DownloadLink("skyrimspecialedition", 12604, file.FileId);
Assert.True(links.Length > 0);
2021-09-27 12:42:46 +00:00
}
}