pull file
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled

This commit is contained in:
2026-02-11 23:32:56 +08:00
commit e519cac94e
656 changed files with 45058 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Ray.BiliBiliTool.Agent;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces;
using Ray.BiliBiliTool.Console;
using Ray.BiliBiliTool.Infrastructure;
using Ray.BiliBiliTool.Infrastructure.Cookie;
using Xunit;
namespace BiliAgentTest;
public class VideoApiTest
{
public VideoApiTest()
{
Program.CreateHost(new[] { "--ENVIRONMENT=Development" });
}
[Fact]
public void GetLiveWalletStatus_Normal_Success()
{
using var scope = Global.ServiceProviderRoot.CreateScope();
var ck = scope.ServiceProvider.GetRequiredService<CookieStrFactory<BiliCookie>>();
var api = scope.ServiceProvider.GetRequiredService<IVideoApi>();
var req = new GetAlreadyDonatedCoinsRequest(248097491);
BiliApiResponse<DonatedCoinsForVideo>? re = api.GetDonatedCoinsForVideo(req, null).Result;
if (ck.Count > 0)
{
Assert.True(re.Code == 0 && re.Data.Multiply >= 0);
}
else
{
Assert.False(re.Code != 0);
}
}
[Fact]
public async Task GetBangumiTest()
{
using var scope = Global.ServiceProviderRoot.CreateScope();
var ck = scope.ServiceProvider.GetRequiredService<CookieStrFactory<BiliCookie>>();
var api = scope.ServiceProvider.GetRequiredService<IVideoApi>();
var req = await api.GetBangumiBySsid(46508, null);
Assert.Equal(0, req.Code);
}
[Fact]
public async Task GetRandomVideoOfRanking()
{
using var scope = Global.ServiceProviderRoot.CreateScope();
var ck = scope.ServiceProvider.GetRequiredService<CookieStrFactory<BiliCookie>>();
var api = scope.ServiceProvider.GetRequiredService<IVideoWithoutCookieApi>();
var req = await api.GetRegionRankingVideosV2();
Assert.Equal(0, req.Code);
}
}