mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-03 02:55:01 +03:00
926790b071
A speed test only stored a speed above zero, so a node that was skipped because its delay test failed, or whose download failed, kept the speed of the previous run. The list showed the skip or error text until it was sorted or refreshed; then the old speed came back and the node sorted as if it had been measured. Clear the stored speed when a speed or mixed test starts.
27 lines
1.2 KiB
C#
27 lines
1.2 KiB
C#
namespace ServiceLib.Tests.Services;
|
|
|
|
public class SpeedtestServiceResultTests
|
|
{
|
|
[Test]
|
|
[Arguments(ESpeedActionType.Speedtest, 0)]
|
|
[Arguments(ESpeedActionType.Mixedtest, 0)]
|
|
[Arguments(ESpeedActionType.Realping, 12.5)]
|
|
public async Task StartingATest_ShouldClearTheLastSpeedOfSpeedTests(ESpeedActionType actionType, double expected)
|
|
{
|
|
var indexId = Guid.NewGuid().ToString();
|
|
ProfileExManager.Instance.SetTestSpeed(indexId, 12.5m);
|
|
|
|
await SetTestResult([new() { IndexId = indexId }], actionType, ResUI.Speedtesting);
|
|
|
|
var profileEx = (await ProfileExManager.Instance.GetProfileExs()).First(t => t.IndexId == indexId);
|
|
await profileEx.Speed.Should().BeEqualTo((decimal)expected);
|
|
}
|
|
|
|
private static Task SetTestResult(List<ServerTestItem> items, ESpeedActionType actionType, string message)
|
|
{
|
|
var service = new SpeedtestService(new Config { SpeedTestItem = new() }, _ => Task.CompletedTask);
|
|
var method = typeof(SpeedtestService).GetMethod("SetTestResultAsync", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
|
return (Task)method.Invoke(service, [items, actionType, message])!;
|
|
}
|
|
}
|