初始提交:WinUI 3 一键运行轮盘工具
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using OneClickRun.Core.Logic;
|
||||
using Xunit;
|
||||
|
||||
namespace OneClickRun.Core.Tests;
|
||||
|
||||
public class DoubleClickStateTests
|
||||
{
|
||||
private static readonly TimeSpan Window = TimeSpan.FromMilliseconds(500);
|
||||
private static readonly DateTimeOffset T0 = new(2025, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
||||
|
||||
[Fact]
|
||||
public void FirstClick_IsPending()
|
||||
{
|
||||
var state = new DoubleClickState();
|
||||
Assert.Equal(DoubleClickOutcome.Pending, state.OnClick(2, T0, Window));
|
||||
Assert.Equal(2, state.PendingIndex);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecondClick_SameSector_WithinWindow_Executes()
|
||||
{
|
||||
var state = new DoubleClickState();
|
||||
state.OnClick(2, T0, Window);
|
||||
Assert.Equal(DoubleClickOutcome.Execute, state.OnClick(2, T0.AddMilliseconds(400), Window));
|
||||
Assert.Equal(-1, state.PendingIndex);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecondClick_AfterWindow_RestartsPending()
|
||||
{
|
||||
var state = new DoubleClickState();
|
||||
state.OnClick(2, T0, Window);
|
||||
Assert.Equal(DoubleClickOutcome.Pending, state.OnClick(2, T0.AddMilliseconds(600), Window));
|
||||
Assert.Equal(2, state.PendingIndex);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecondClick_DifferentSector_MovesPending()
|
||||
{
|
||||
var state = new DoubleClickState();
|
||||
state.OnClick(2, T0, Window);
|
||||
Assert.Equal(DoubleClickOutcome.Pending, state.OnClick(3, T0.AddMilliseconds(200), Window));
|
||||
Assert.Equal(3, state.PendingIndex);
|
||||
Assert.Equal(DoubleClickOutcome.Execute, state.OnClick(3, T0.AddMilliseconds(400), Window));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reset_ClearsPending()
|
||||
{
|
||||
var state = new DoubleClickState();
|
||||
state.OnClick(1, T0, Window);
|
||||
state.Reset();
|
||||
Assert.Equal(-1, state.PendingIndex);
|
||||
Assert.False(state.IsPending(T0.AddMilliseconds(1), Window));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user