Files
Terminal.Gui/UnitTests/View/TitleTests.cs
Tig b267e1698e V2 fix warnings (#3671)
* Fixed NumericUpDown warning

* Fixed Aot Warning

* Fixed warnings in Application.cs

* Fixed more NumericUpDown warning

* Fixed CommandImpl warning

* Fixed Thickness warnings

* Fixed Label warning

* Fixed warning

* Fixed menubar test warning

* Fixed warnings

* Fixed warnings

* Removed dead code

* Fixed warnings
2024-08-19 10:09:15 -06:00

74 lines
2.0 KiB
C#

using System.Text;
using Xunit.Abstractions;
namespace Terminal.Gui.ViewTests;
public class TitleTests
{
// 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);
}
}