Cosmos/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/EventsTest.cs
2020-08-21 13:55:54 -05:00

36 lines
791 B
C#

using System;
using Cosmos.TestRunner;
namespace Cosmos.Compiler.Tests.Bcl.System
{
internal class TestClass
{
private static bool handlerInvoked;
public event EventHandler EventFired = (sender, args) =>
{
handlerInvoked = true;
};
private void OnEventFired(EventArgs e)
{
EventHandler handler = EventFired;
handler?.Invoke(this, e);
}
public bool ExecuteTest()
{
OnEventFired(null);
return handlerInvoked;
}
}
public class EventsTest
{
public static void Execute()
{
var test = new TestClass();
Assert.IsTrue(test.ExecuteTest(), "Event handler was not invoked.");
}
}
}