12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Text;
- using Xunit.Abstractions;
- namespace Terminal.Gui.ViewTests;
- public class TitleTests (ITestOutputHelper output)
- {
- // Unit tests that verify look & feel of title are in BorderTests.cs
- [Fact]
- public void Set_Title_Fires_TitleChanged ()
- {
- var r = new View ();
- Assert.Equal (string.Empty, r.Title);
- string expectedOld = null;
- string expected = null;
- r.TitleChanged += (s, args) =>
- {
- Assert.Equal (r.Title, args.CurrentValue);
- };
- expected = "title";
- expectedOld = r.Title;
- r.Title = expected;
- Assert.Equal (expected, r.Title);
- r.Dispose ();
- }
- [Fact]
- public void Set_Title_Fires_TitleChanging ()
- {
- var r = new View ();
- Assert.Equal (string.Empty, r.Title);
- string expectedOld = null;
- string expectedDuring = null;
- string expectedAfter = null;
- var cancel = false;
- r.TitleChanging += (s, args) =>
- {
- Assert.Equal (expectedOld, args.CurrentValue);
- Assert.Equal (expectedDuring, args.NewValue);
- args.Cancel = cancel;
- };
- expectedOld = string.Empty;
- r.Title = expectedDuring = expectedAfter = "title";
- Assert.Equal (expectedAfter, r.Title);
- expectedOld = r.Title;
- r.Title = expectedDuring = expectedAfter = "a different title";
- Assert.Equal (expectedAfter, r.Title);
- // Now setup cancelling the change and change it back to "title"
- cancel = true;
- expectedOld = r.Title;
- r.Title = expectedDuring = "title";
- Assert.Equal (expectedAfter, r.Title);
- r.Dispose ();
- }
- // Setting Text does NOT set the HotKey
- [Fact]
- public void Title_Does_Set_HotKey ()
- {
- var view = new View { HotKeySpecifier = (Rune)'_', Title = "_Hello World" };
- Assert.Equal (Key.H, view.HotKey);
- }
- }
|