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
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:
23
test/BiliAgentTest/BiliAgentTest.csproj
Normal file
23
test/BiliAgentTest/BiliAgentTest.csproj
Normal file
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<UserSecretsId>a6e5b261-0fe9-49e1-82e1-02349db119b4</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="xunit" />
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Ray.BiliBiliTool.Console\Ray.BiliBiliTool.Console.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
37
test/BiliAgentTest/LiveTraceApiTest.cs
Normal file
37
test/BiliAgentTest/LiveTraceApiTest.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Ray.BiliBiliTool.Agent;
|
||||
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;
|
||||
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live;
|
||||
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 LiveTraceApiTest
|
||||
{
|
||||
public LiveTraceApiTest()
|
||||
{
|
||||
Program.CreateHost(new[] { "--ENVIRONMENT=Development" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WebHeartBeat_Normal_Success()
|
||||
{
|
||||
using var scope = Global.ServiceProviderRoot.CreateScope();
|
||||
|
||||
var ck = scope.ServiceProvider.GetRequiredService<CookieStrFactory<BiliCookie>>();
|
||||
var api = scope.ServiceProvider.GetRequiredService<ILiveTraceApi>();
|
||||
|
||||
var request = new WebHeartBeatRequest(63666, 60);
|
||||
|
||||
var re = api.WebHeartBeat(request, null).Result;
|
||||
|
||||
Assert.Equal(0, re.Code);
|
||||
Assert.Equal("0", re.Message);
|
||||
Assert.Equal(60, re.Data.Next_interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
64
test/BiliAgentTest/VideoApiTest.cs
Normal file
64
test/BiliAgentTest/VideoApiTest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user