修复测试用例错误

This commit is contained in:
zhengxuan.zhang
2026-05-18 15:32:00 +08:00
parent e5cfbf9dd5
commit dcc15f62d1
10 changed files with 88 additions and 174 deletions
@@ -368,8 +368,6 @@ namespace XplorePlane.Tests.ViewModels
method?.Invoke(vm, null);
}
DoEvents();
Assert.True(vm.TrendData.Count <= 60,
$"TrendData should not exceed 60 points, but has {vm.TrendData.Count}");
}
@@ -389,8 +387,6 @@ namespace XplorePlane.Tests.ViewModels
.GetMethod("UpdateTrendData", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
method?.Invoke(vm, null);
DoEvents();
Assert.NotEmpty(vm.TrendData);
var point = vm.TrendData.Last();
Assert.True(point.Timestamp > DateTime.MinValue, "TrendDataPoint.Timestamp should be set");
@@ -418,8 +414,6 @@ namespace XplorePlane.Tests.ViewModels
.GetMethod("UpdateTrendData", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
method?.Invoke(vm, null);
DoEvents();
var expectedTotal = vm.Metrics.Sum(m => m.EventsPerSecond);
var lastPoint = vm.TrendData.Last();
Assert.Equal(expectedTotal, lastPoint.Value);
@@ -457,7 +451,6 @@ namespace XplorePlane.Tests.ViewModels
});
await Task.Delay(200);
DoEvents();
Assert.Null(caughtException);
}
@@ -479,31 +472,5 @@ namespace XplorePlane.Tests.ViewModels
_mockAppStateService.Object,
new StateChangedEventArgs<MotionState>(oldState, newState));
}
private void RaiseRaySourceStateEvent()
{
var oldState = new RaySourceState(false, 100.0, 5.0);
var newState = new RaySourceState(true, 160.0, 8.0);
_mockAppStateService.Raise(
s => s.RaySourceStateChanged += null,
_mockAppStateService.Object,
new StateChangedEventArgs<RaySourceState>(oldState, newState));
}
/// <summary>
/// 处理 Dispatcher 队列中的所有待处理消息
/// Process all pending messages in the Dispatcher queue
/// </summary>
private void DoEvents()
{
var frame = new DispatcherFrame();
_dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(
delegate (object f)
{
((DispatcherFrame)f).Continue = false;
return null;
}), frame);
Dispatcher.PushFrame(frame);
}
}
}