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:
13
test/LogTest/LogConstants.cs
Normal file
13
test/LogTest/LogConstants.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class LogConstants
|
||||
{
|
||||
public static string Msg =
|
||||
"ℹ 版本号:\"1.1.0\"\r\nℹ 开源地址:\"https://github.com/RayWangQvQ/BiliBiliTool\"\r\nℹ 当前环境:\"Development\" \r\n\r\nℹ -----开始每日任务-----\r\n\r\nℹ ---开始【\"登录\"】---\r\nℹ 登录成功,用户名: \"在*楼\"\r\nℹ 硬币余额: 666.5\r\nℹ 距离升级到Lv6还有: 258天\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"观看、分享视频\"】---\r\nℹ 获取随机视频:\"【周深&李克勤】“勤深深”组合《突如其来的爱情》日语+粤语无缝切换天作之合!\"\r\nℹ 今天已经观看过了,不需要再看啦\r\nℹ 视频分享成功\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"投币\"】---\r\nℹ 今日已投0枚硬币,目标是投5枚,还需再投5枚\r\nℹ 投币前余额为 : 666.5\r\nℹ 为“\"【本宫吐槽】变态赛高:传说中的神番《永生之酒》,究竟神在哪里?\"”投币成功\r\nℹ 为“\"鲲鹏计算引领多样性计算新时代【思维+】\"”投币成功\r\nℹ 为“\"【瞎看什么】激突!王者告诉你爸爸的爸爸叫什么!\"”投币成功\r\nℹ 为“\"带着18个妹子去广东吃吃吃,没想到却把她们苦哭了!\"”投币成功\r\nℹ 为“\"沙盘推演:红25军长征记(第一阶段)激战独树镇 徐海东血战庾家河 年龄最小的长征队伍\"”投币成功\r\nℹ 投币任务完成,余额为: 661.5\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"漫画签到\"】---\r\nℹ 完成漫画签到\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"直播中心签到\"】---\r\nℹ 直播签到成功,本次签到获得\"3000点用户经验,2根辣条\",\"\"\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"直播中心银瓜子兑换硬币\"】---\r\nℹ 银瓜子兑换硬币失败,原因:\"银瓜子余额不足\"\r\nℹ 当前银瓜子余额: 564\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"每月领取大会员福利\"】---\r\nℹ 目标领取日期为1号,今天是29号,跳过领取任务\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"每月领取大会员漫画权益\"】---\r\nℹ 目标领取日期为1号,今天是29号,跳过领取任务\r\nℹ ---结束---\r\n\r\nℹ ---开始【\"每月为自己充电\"】---\r\nℹ 目标充电日期为31号,今天是29号,跳过充电任务\r\nℹ ---结束---\r\n\r\nℹ -----全部任务已执行结束-----\r\n\r\nℹ 开始推送\r\n";
|
||||
|
||||
public static string Msg2 =
|
||||
$"1{Environment.NewLine}2{Environment.NewLine}{Environment.NewLine}3";
|
||||
}
|
||||
}
|
||||
22
test/LogTest/LogTest.csproj
Normal file
22
test/LogTest/LogTest.csproj
Normal file
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<UserSecretsId>5bc79f80-380e-4bcf-9c0b-30e98db3b935</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="xunit" />
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Ray.BiliBiliTool.Console\Ray.BiliBiliTool.Console.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
41
test/LogTest/TestCoolPush.cs
Normal file
41
test/LogTest/TestCoolPush.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.CoolPushBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestCoolPush
|
||||
{
|
||||
private string _key;
|
||||
|
||||
public TestCoolPush()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });
|
||||
|
||||
_key = Global.ConfigurationRoot["Serilog:WriteTo:7:Args:sKey"];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test2()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_key))
|
||||
{
|
||||
Debug.WriteLine("CoolPush key not configured, skipping test");
|
||||
return;
|
||||
}
|
||||
|
||||
var client = new CoolPushApiClient(_key);
|
||||
string msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg);
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
test/LogTest/TestDingTalk.cs
Normal file
43
test/LogTest/TestDingTalk.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.DingTalkBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestDingTalk
|
||||
{
|
||||
private string _key;
|
||||
|
||||
public TestDingTalk()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(["ENVIRONMENT=Development"]);
|
||||
|
||||
// 添加空值检查
|
||||
if (Global.ConfigurationRoot != null)
|
||||
{
|
||||
_key = Global.ConfigurationRoot["Serilog:WriteTo:5:Args:webHookUrl"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_key = "test_key"; // 默认测试值
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test2()
|
||||
{
|
||||
var client = new DingTalkApiClient(_key);
|
||||
|
||||
var title = "这是标题";
|
||||
var msg = LogConstants.Msg2 + "开始推送";
|
||||
|
||||
var result = await client.PushMessageAsync(msg, title);
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
test/LogTest/TestMicrosoftTeams.cs
Normal file
38
test/LogTest/TestMicrosoftTeams.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.MicrosoftTeamsBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestMicrosoftTeams
|
||||
{
|
||||
private string _webhook;
|
||||
|
||||
public TestMicrosoftTeams()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });
|
||||
|
||||
_webhook = Global.ConfigurationRoot["Serilog:WriteTo:10:Args:webhook"];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test()
|
||||
{
|
||||
var client = new MicrosoftTeamsApiClient(webhook: _webhook);
|
||||
|
||||
var msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg);
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
|
||||
Assert.True(result.StatusCode == System.Net.HttpStatusCode.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
test/LogTest/TestPushPlus.cs
Normal file
40
test/LogTest/TestPushPlus.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.PushPlusBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestPushPlus
|
||||
{
|
||||
private string _token;
|
||||
private string _channel;
|
||||
private string _webhook;
|
||||
|
||||
public TestPushPlus()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });
|
||||
|
||||
_token = Global.ConfigurationRoot["Serilog:WriteTo:9:Args:token"];
|
||||
_channel = Global.ConfigurationRoot["Serilog:WriteTo:9:Args:channel"];
|
||||
_webhook = Global.ConfigurationRoot["Serilog:WriteTo:9:Args:webhook"];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test2()
|
||||
{
|
||||
var client = new PushPlusApiClient(_token, channel: _channel, webhook: _webhook);
|
||||
|
||||
var msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg);
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
57
test/LogTest/TestServerChan.cs
Normal file
57
test/LogTest/TestServerChan.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.ServerChanBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestServerChan
|
||||
{
|
||||
private string _scKey;
|
||||
private string _turboScKey;
|
||||
|
||||
public TestServerChan()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });
|
||||
|
||||
_scKey = Global.ConfigurationRoot["Serilog:WriteTo:6:Args:scKey"];
|
||||
_turboScKey = Global.ConfigurationRoot["Serilog:WriteTo:6:Args:turboScKey"];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test()
|
||||
{
|
||||
var client = new ServerChanApiClient(_scKey);
|
||||
|
||||
string msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg);
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
|
||||
/*
|
||||
* server酱的换行有问题,一个newline换不了,要两个
|
||||
*/
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestTurbo()
|
||||
{
|
||||
var client = new ServerChanTurboApiClient(_turboScKey);
|
||||
|
||||
string msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg, "测试");
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
|
||||
/*
|
||||
* server酱的换行有问题,一个newline换不了,要两个
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
40
test/LogTest/TestTelegram.cs
Normal file
40
test/LogTest/TestTelegram.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.TelegramBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestTelegram
|
||||
{
|
||||
private string _botToken;
|
||||
private string _chatId;
|
||||
|
||||
public TestTelegram()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(["ENVIRONMENT=Development"]);
|
||||
|
||||
_botToken = Global.ConfigurationRoot?["Serilog:WriteTo:3:Args:botToken"];
|
||||
_chatId = Global.ConfigurationRoot?["Serilog:WriteTo:3:Args:chatId"];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test2()
|
||||
{
|
||||
var client = new TelegramApiClient(_botToken, _chatId);
|
||||
|
||||
string msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg, "标题");
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
|
||||
/*
|
||||
* 如果指定markdown,星号会导致推送失败
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
37
test/LogTest/TestWorkWeiXin.cs
Normal file
37
test/LogTest/TestWorkWeiXin.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.WorkWeiXinBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestWorkWeiXin
|
||||
{
|
||||
private string _key;
|
||||
|
||||
public TestWorkWeiXin()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });
|
||||
|
||||
_key = Global.ConfigurationRoot["Serilog:WriteTo:4:Args:webHookUrl"];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test2()
|
||||
{
|
||||
var client = new WorkWeiXinApiClient(_key, WorkWeiXinMsgType.text);
|
||||
|
||||
//string msg = LogConstants.Msg;
|
||||
string msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg);
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
test/LogTest/TestWorkWeiXinApp.cs
Normal file
43
test/LogTest/TestWorkWeiXinApp.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Ray.BiliBiliTool.Console;
|
||||
using Ray.BiliBiliTool.Infrastructure;
|
||||
using Ray.Serilog.Sinks.WorkWeiXinAppBatched;
|
||||
using Xunit;
|
||||
|
||||
namespace LogTest
|
||||
{
|
||||
public class TestWorkWeiXinApp
|
||||
{
|
||||
private string _agentId;
|
||||
private string _secret;
|
||||
private string _corpId;
|
||||
private string _toUser;
|
||||
|
||||
public TestWorkWeiXinApp()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });
|
||||
|
||||
_agentId = Global.ConfigurationRoot["Serilog:WriteTo:11:Args:agentId"];
|
||||
_secret = Global.ConfigurationRoot["Serilog:WriteTo:11:Args:secret"];
|
||||
_corpId = Global.ConfigurationRoot["Serilog:WriteTo:11:Args:corpId"];
|
||||
|
||||
_toUser = Global.ConfigurationRoot["Serilog:WriteTo:11:Args:toUser"];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test()
|
||||
{
|
||||
var client = new WorkWeiXinAppApiClient(_corpId, _agentId, _secret, _toUser);
|
||||
|
||||
var msg = LogConstants.Msg2;
|
||||
|
||||
var result = await client.PushMessageAsync(msg);
|
||||
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
|
||||
|
||||
Assert.True(result.StatusCode == System.Net.HttpStatusCode.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user