mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
Add test for eventhandler
This commit is contained in:
parent
89e5f33a5a
commit
434d3a6171
2 changed files with 38 additions and 1 deletions
|
|
@ -37,6 +37,7 @@ namespace Cosmos.Compiler.Tests.Bcl
|
||||||
BitConverterTest.Execute();
|
BitConverterTest.Execute();
|
||||||
UnsafeCodeTest.Execute();
|
UnsafeCodeTest.Execute();
|
||||||
DelegatesTest.Execute();
|
DelegatesTest.Execute();
|
||||||
|
EventsTest.Execute();
|
||||||
RandomTests.Execute();
|
RandomTests.Execute();
|
||||||
|
|
||||||
// System.Collections
|
// System.Collections
|
||||||
|
|
|
||||||
36
Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/EventsTest.cs
Normal file
36
Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/EventsTest.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue