2
0

TextFieldFluentTests.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.IO.Abstractions;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using TerminalGuiFluentTesting;
  9. using TerminalGuiFluentTestingXunit;
  10. using Xunit.Abstractions;
  11. namespace IntegrationTests.FluentTests;
  12. public class TextFieldFluentTests
  13. {
  14. private readonly TextWriter _out;
  15. public TextFieldFluentTests (ITestOutputHelper outputHelper)
  16. {
  17. _out = new TestOutputWriter (outputHelper);
  18. }
  19. [Theory]
  20. [ClassData (typeof (TestDrivers))]
  21. public void TextField_Cursor_AtEnd_WhenTyping (TestDriver d)
  22. {
  23. // Simulates typing abcd into a TextField with width 3 (wide enough to render 2 characters only)
  24. using var c = With.A<Window> (100, 20, d, _out)
  25. .Add (new TextField () { Width = 3 })
  26. .Focus<TextField> ()
  27. //.WaitIteration ()
  28. //.AssertCursorPosition (new Point (1, 1)) // Initial cursor position (because Window has border)
  29. //.EnqueueKeyEvent (Key.A)
  30. //.WaitIteration ()
  31. //.ScreenShot ("After typing first letter", _out)
  32. //.AssertCursorPosition (new Point (2, 1)) // Cursor moves along as letter is pressed
  33. //.EnqueueKeyEvent (Key.B)
  34. //.WaitIteration ()
  35. //.AssertCursorPosition (new Point (3, 1)) // Cursor moves along as letter is pressed
  36. //.EnqueueKeyEvent (Key.C)
  37. //.WaitIteration ()
  38. //.ScreenShot ("After typing all letters",_out)
  39. //.AssertCursorPosition (new Point (3, 1)) // Cursor stays where it is because we are at end of TextField
  40. //.EnqueueKeyEvent (Key.D)
  41. //.WaitIteration ()
  42. //.ScreenShot ("Typing one more letter", _out)
  43. //.AssertCursorPosition (new Point (3, 1)) // Cursor still stays at end of TextField
  44. //.WriteOutLogs (_out)
  45. //.Stop ()
  46. ;
  47. }
  48. }