mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-02 23:39:44 +08:00
获取钓鱼框成功以及超时失败的两个单元测试
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using BehaviourTree;
|
||||
using BetterGenshinImpact.GameTask.AutoFishing;
|
||||
using BetterGenshinImpact.GameTask.Model.Area.Converter;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using BetterGenshinImpact.Core.Recognition.ONNX.YOLO;
|
||||
using Microsoft.Extensions.Time.Testing;
|
||||
|
||||
namespace BetterGenshinImpact.UnitTest.GameTaskTests.AutoFishingTests
|
||||
{
|
||||
public partial class BehavioursTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(@"20250306111752769_GetFishBoxArea_Succeeded.png")]
|
||||
/// <summary>
|
||||
/// 测试获取钓鱼拉扯框,结果为成功
|
||||
/// </summary>
|
||||
public void GetFishBoxArea_ShouldSuccess(string screenshot1080p)
|
||||
{
|
||||
//
|
||||
Bitmap bitmap = new Bitmap(@$"..\..\..\Assets\AutoFishing\{screenshot1080p}");
|
||||
var imageRegion = new GameCaptureRegion(bitmap, 0, 0, drawContent: new FakeDrawContent());
|
||||
|
||||
var blackboard = new Blackboard(null, sleep: i => { });
|
||||
|
||||
//
|
||||
GetFishBoxArea sut = new GetFishBoxArea("-", blackboard, new FakeLogger(), false);
|
||||
BehaviourStatus actual = sut.Tick(imageRegion);
|
||||
|
||||
//
|
||||
Assert.Equal(BehaviourStatus.Succeeded, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"20250306111752769_GetFishBoxArea_Succeeded.png")]
|
||||
[InlineData(@"202503012143011486@900p.png")]
|
||||
/// <summary>
|
||||
/// 测试获取钓鱼拉扯框,超时后,结果为失败
|
||||
/// </summary>
|
||||
public void GetFishBoxArea_ShouldFail(string screenshot1080p)
|
||||
{
|
||||
//
|
||||
Bitmap bitmap = new Bitmap(@$"..\..\..\Assets\AutoFishing\{screenshot1080p}");
|
||||
var imageRegion = new GameCaptureRegion(bitmap, 0, 0, drawContent: new FakeDrawContent());
|
||||
|
||||
var blackboard = new Blackboard(null, sleep: i => { });
|
||||
|
||||
FakeTimeProvider fakeTimeProvider = new FakeTimeProvider();
|
||||
|
||||
//
|
||||
GetFishBoxArea sut = new GetFishBoxArea("-", blackboard, new FakeLogger(), false, fakeTimeProvider);
|
||||
BehaviourStatus actual = sut.Tick(imageRegion);
|
||||
|
||||
//
|
||||
Assert.NotEqual(BehaviourStatus.Failed, actual);
|
||||
|
||||
//
|
||||
fakeTimeProvider.Advance(TimeSpan.FromSeconds(6));
|
||||
|
||||
//
|
||||
actual = sut.Tick(imageRegion);
|
||||
|
||||
//
|
||||
Assert.Equal(BehaviourStatus.Failed, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user