Update Added/Removed and other events to use `EventHandler

This commit is contained in:
tznind
2023-03-11 11:05:20 +00:00
parent 7764006932
commit 9c4f3eda16
16 changed files with 72 additions and 52 deletions

View File

@@ -143,9 +143,9 @@ namespace Terminal.Gui.ApplicationTests {
};
Application.RunState runstate = null;
Action<Application.RunState> NewRunStateFn = (rs) => {
Assert.NotNull (rs);
runstate = rs;
EventHandler<RunStateEventArgs> NewRunStateFn = (s, e) => {
Assert.NotNull (e.State);
runstate = e.State;
};
Application.NotifyNewRunState += NewRunStateFn;
@@ -188,9 +188,9 @@ namespace Terminal.Gui.ApplicationTests {
Application.InternalInit (() => topLevel = new TestToplevel (), new FakeDriver ());
Application.RunState runstate = null;
Action<Application.RunState> NewRunStateFn = (rs) => {
Assert.NotNull (rs);
runstate = rs;
EventHandler<RunStateEventArgs> NewRunStateFn = (s, e) => {
Assert.NotNull (e.State);
runstate = e.State;
};
Application.NotifyNewRunState += NewRunStateFn;
@@ -730,7 +730,7 @@ namespace Terminal.Gui.ApplicationTests {
var top = Application.Top;
var isQuiting = false;
top.Closing += (e) => {
top.Closing += (s,e) => {
isQuiting = true;
e.Cancel = true;
};

View File

@@ -775,7 +775,7 @@ namespace Terminal.Gui.ConfigurationTests {
ConfigurationManager.Updated += ConfigurationManager_Updated;
bool fired = false;
void ConfigurationManager_Updated (ConfigurationManager.ConfigurationManagerEventArgs obj)
void ConfigurationManager_Updated (object sender, ConfigurationManager.ConfigurationManagerEventArgs obj)
{
fired = true;
// assert
@@ -801,7 +801,7 @@ namespace Terminal.Gui.ConfigurationTests {
ConfigurationManager.Reset ();
ConfigurationManager.Applied += ConfigurationManager_Applied;
bool fired = false;
void ConfigurationManager_Applied (ConfigurationManager.ConfigurationManagerEventArgs obj)
void ConfigurationManager_Applied (object sender, ConfigurationManager.ConfigurationManagerEventArgs obj)
{
fired = true;
// assert

View File

@@ -238,11 +238,11 @@ namespace Terminal.Gui.CoreTests {
var v = new View (new Rect (0, 0, 10, 24));
var t = new View ();
v.Added += (View e) => {
Assert.True (v.SuperView == e);
v.Added += (s,e) => {
Assert.True (v.SuperView == e.View);
};
v.Removed += (View e) => {
v.Removed += (s, e) => {
Assert.True (v.SuperView == null);
};
@@ -654,21 +654,21 @@ namespace Terminal.Gui.CoreTests {
int tc = 0, wc = 0, v1c = 0, v2c = 0, sv1c = 0;
w.Added += (e) => {
Assert.Equal (e.Frame.Width, w.Frame.Width);
Assert.Equal (e.Frame.Height, w.Frame.Height);
w.Added += (s,e) => {
Assert.Equal (e.View.Frame.Width, w.Frame.Width);
Assert.Equal (e.View.Frame.Height, w.Frame.Height);
};
v1.Added += (e) => {
Assert.Equal (e.Frame.Width, v1.Frame.Width);
Assert.Equal (e.Frame.Height, v1.Frame.Height);
v1.Added += (s, e) => {
Assert.Equal (e.View.Frame.Width, v1.Frame.Width);
Assert.Equal (e.View.Frame.Height, v1.Frame.Height);
};
v2.Added += (e) => {
Assert.Equal (e.Frame.Width, v2.Frame.Width);
Assert.Equal (e.Frame.Height, v2.Frame.Height);
v2.Added += (s, e) => {
Assert.Equal (e.View.Frame.Width, v2.Frame.Width);
Assert.Equal (e.View.Frame.Height, v2.Frame.Height);
};
sv1.Added += (e) => {
Assert.Equal (e.Frame.Width, sv1.Frame.Width);
Assert.Equal (e.Frame.Height, sv1.Frame.Height);
sv1.Added += (s, e) => {
Assert.Equal (e.View.Frame.Width, sv1.Frame.Width);
Assert.Equal (e.View.Frame.Height, sv1.Frame.Height);
};
t.Initialized += (s, e) => {

View File

@@ -163,7 +163,7 @@ namespace Terminal.Gui.TopLevelTests {
top.Closed += (s, e) => eventInvoked = "Closed";
top.OnClosed (top);
Assert.Equal ("Closed", eventInvoked);
top.Closing += (e) => eventInvoked = "Closing";
top.Closing += (s,e) => eventInvoked = "Closing";
top.OnClosing (new ToplevelClosingEventArgs (top));
Assert.Equal ("Closing", eventInvoked);
top.AllChildClosed += (s, e) => eventInvoked = "AllChildClosed";
@@ -356,7 +356,7 @@ namespace Terminal.Gui.TopLevelTests {
var top = Application.Top;
top.Add (win1, win2);
top.Loaded += (s, e) => isRunning = true;
top.Closing += (_) => isRunning = false;
top.Closing += (s,e) => isRunning = false;
Application.Begin (top);
top.Running = true;
@@ -465,7 +465,7 @@ namespace Terminal.Gui.TopLevelTests {
var tf2W2 = new TextField ("Text2 on Win2") { X = Pos.Left (tf1W2), Width = Dim.Fill () };
win2.Add (lblTf1W2, tf1W2, lblTvW2, tvW2, lblTf2W2, tf2W2);
win1.Closing += (_) => isRunning = false;
win1.Closing += (s, e) => isRunning = false;
Assert.Null (top.Focused);
Assert.Equal (top, Application.Current);
Assert.True (top.IsCurrentTop);
@@ -587,7 +587,7 @@ namespace Terminal.Gui.TopLevelTests {
var view = new View ();
view.Added += View_Added;
void View_Added (View obj)
void View_Added (object sender, ViewEventArgs e)
{
Assert.Throws<NullReferenceException> (() => Application.Top.AlternateForwardKeyChanged += (s,e) => alternateForwardKey = e.OldKey);
Assert.Throws<NullReferenceException> (() => Application.Top.AlternateBackwardKeyChanged += (s,e) => alternateBackwardKey = e.OldKey);