mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 16:27:55 +01:00
* initial commit * All tests pass * Updated readme * Revert "All tests pass" This reverts commit94ac462350. * Revert "initial commit" This reverts commit36d92cc4e5. * Moved Terminal.Gui files around * Nuked .Graphs namespace * Nuked .Graphs namespace * Nuked .Trees namespace * Nuked .Configuration namespace * Nuked .Configuration namespace * All tests pass * tweaked tests * removed unneeded usings * re-enabled scrollview tests * move scrollview test to ScrollViewTests * Moved view navigation related tests to separate cs file * Moved view scrollbarview related tests ScrollBarTestse * Refactored View tests into smaller files * Refactored driver tests * Fixed a ton of BUGBUGs
75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using NStack;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml.Linq;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
|
|
|
|
// Alias Console to MockConsole so we don't accidentally use Console
|
|
using Console = Terminal.Gui.FakeConsole;
|
|
|
|
namespace Terminal.Gui.ViewTests {
|
|
public class TitleTests {
|
|
readonly ITestOutputHelper output;
|
|
|
|
public TitleTests (ITestOutputHelper output)
|
|
{
|
|
this.output = output;
|
|
}
|
|
|
|
[Fact]
|
|
public void Set_Title_Fires_TitleChanging ()
|
|
{
|
|
var r = new View ();
|
|
Assert.Equal (ustring.Empty, r.Title);
|
|
|
|
string expectedOld = null;
|
|
string expectedDuring = null;
|
|
string expectedAfter = null;
|
|
bool cancel = false;
|
|
r.TitleChanging += (s, args) => {
|
|
Assert.Equal (expectedOld, args.OldTitle);
|
|
Assert.Equal (expectedDuring, args.NewTitle);
|
|
args.Cancel = cancel;
|
|
};
|
|
|
|
expectedOld = string.Empty;
|
|
r.Title = expectedDuring = expectedAfter = "title";
|
|
Assert.Equal (expectedAfter, r.Title.ToString ());
|
|
|
|
expectedOld = r.Title.ToString ();
|
|
r.Title = expectedDuring = expectedAfter = "a different title";
|
|
Assert.Equal (expectedAfter, r.Title.ToString ());
|
|
|
|
// Now setup cancelling the change and change it back to "title"
|
|
cancel = true;
|
|
expectedOld = r.Title.ToString ();
|
|
r.Title = expectedDuring = "title";
|
|
Assert.Equal (expectedAfter, r.Title.ToString ());
|
|
r.Dispose ();
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public void Set_Title_Fires_TitleChanged ()
|
|
{
|
|
var r = new View ();
|
|
Assert.Equal (ustring.Empty, r.Title);
|
|
|
|
string expectedOld = null;
|
|
string expected = null;
|
|
r.TitleChanged += (s, args) => {
|
|
Assert.Equal (expectedOld, args.OldTitle);
|
|
Assert.Equal (r.Title, args.NewTitle);
|
|
};
|
|
|
|
expected = "title";
|
|
expectedOld = r.Title.ToString ();
|
|
r.Title = expected;
|
|
Assert.Equal (expected, r.Title.ToString ());
|
|
}
|
|
|
|
}
|
|
}
|