public void TestTextBoxBlinkState() { var app = new CliTestHarness(this.TestContext, 9, 1); app.LayoutRoot.Add(new TextBox() { Value = "SomeText".ToWhite() }).Fill(); app.SetTimeout(() => app.Stop(), TimeSpan.FromSeconds(1.2)); app.Start().Wait(); app.AssertThisTestMatchesLKG(); }
public void TestPlaybackEndToEnd() { int w = 10, h = 1; var temp = Path.GetTempFileName(); using (var stream = File.OpenWrite(temp)) { var writer = new ConsoleBitmapStreamWriter(stream) { CloseInnerStream = false }; var bitmap = new ConsoleBitmap(w, h); for (var i = 0; i < bitmap.Width; i++) { bitmap.Pen = new ConsoleCharacter(' '); bitmap.FillRect(0, 0, bitmap.Width, bitmap.Height); bitmap.Pen = new ConsoleCharacter(' ', backgroundColor: ConsoleColor.Red); bitmap.DrawPoint(i, 0); writer.WriteFrame(bitmap, true, TimeSpan.FromSeconds(.5 * i)); } writer.Dispose(); } var app = new CliTestHarness(this.TestContext, 80, 30); app.QueueAction(() => { var player = app.LayoutRoot.Add(new ConsoleBitmapPlayer()).Fill(); player.Load(File.OpenRead(temp)); app.SetTimeout(() => app.SendKey(new ConsoleKeyInfo('p', ConsoleKey.P, false, false, false)), TimeSpan.FromMilliseconds(100)); var playStarted = false; player.SubscribeForLifetime(nameof(player.State), () => { if (player.State == PlayerState.Playing) { playStarted = true; } else if (player.State == PlayerState.Stopped && playStarted) { app.Stop(); } }, app); }); app.Start().Wait(); Thread.Sleep(100); app.AssertThisTestMatchesLKGFirstAndLastFrame(); }