public void TestBasicGrid() { var grid = new Grid(new List <object> { new { Name = "Adam", State = "Washington" }, new { Name = "Bob", State = "New Jersey" } }); var app = new CliTestHarness(this.TestContext, 80, 30); app.LayoutRoot.Add(grid).Fill(); app.QueueAction(() => { app.SetTimeout(() => app.SendKey(new ConsoleKeyInfo((char)0, ConsoleKey.DownArrow, false, false, false)), TimeSpan.FromMilliseconds(333)); app.SetTimeout(() => app.SendKey(new ConsoleKeyInfo((char)0, ConsoleKey.UpArrow, false, false, false)), TimeSpan.FromMilliseconds(666)); app.SetTimeout(() => app.Stop(), TimeSpan.FromMilliseconds(1000)); }); app.Start().Wait(); app.AssertThisTestMatchesLKG(); }
public async Task TestAnimatorInTimeAsync() { var app = new CliTestHarness(TestContext, 0, 0, 40, 1, true); var delayProvider = new KeyframeDelayProvider(app); app.QueueAction(() => { var panel = app.LayoutRoot.Add(new SpacetimePanel(40, 1)); panel.SpaceTime.Start(nameof(TestAnimatorInTimeAsync)); app.SecondsBetweenKeyframes = panel.SpaceTime.Increment.TotalSeconds; panel.SpaceTime.QueueAction("Test", async() => { panel.RealTimeViewing.Enabled = false; var element = panel.SpaceTime.Add(new SpacialElement()); element.ResizeTo(1, 1); await app.PaintAndRecordKeyFrameAsync(); await Animator.AnimateAsync(new FloatAnimatorOptions() { From = 0, To = panel.Width - 1, Duration = 3000, Setter = v => element.MoveTo(v, element.Top), DelayProvider = delayProvider, AutoReverse = true, AutoReverseDelay = 1000, }); panel.SpaceTime.Stop(); app.Stop(); }); }); await app.Start().AsAwaitable(); app.AssertThisTestMatchesLKG(); Console.WriteLine(delayProvider.DelayCount + " delays"); Console.WriteLine(app.TotalPaints + " paints"); Console.WriteLine(app.TotalCycles + " cycles"); }