using XFEEDToolBox.Core.Galaxy; using XFEExtension.NetCore.XUnit.Attributes; namespace XFEEDToolBox.Test; [TestFixture] public sealed class GalaxyViewportThrottleTests { [Test] public void ContinuousInputPublishesProgressInsteadOfPostponingUntilRelease() { var throttle=new GalaxyViewportThrottle();var times=new List(); for(var t=0;t<=1000;t+=10){throttle.Changed();if(throttle.TryPublish(t))times.Add(t);} Check.Equal(6,times.Count);Check.Equal(0d,times[0]);Check.Equal(1000d,times[^1]); Check.That(times.Zip(times.Skip(1)).All(pair=>pair.Second-pair.First>=200)); } [Test] public void EndingTheGesturePublishesTheLatestPoseImmediatelyAndIdleDoesNotRepeat() { var throttle=new GalaxyViewportThrottle();throttle.Changed();Check.That(throttle.TryPublish(0)); throttle.Changed();Check.That(!throttle.TryPublish(45));Check.That(throttle.TryPublish(45,true)); Check.That(!throttle.Pending&&!throttle.TryPublish(1000)); throttle.Changed();Check.Equal(155d,throttle.Delay(90)); throttle.Reset();Check.That(!throttle.Pending);throttle.Changed();Check.That(throttle.TryPublish(91)); } }