mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 04:18:43 +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();
|
||||
UnsafeCodeTest.Execute();
|
||||
DelegatesTest.Execute();
|
||||
EventsTest.Execute();
|
||||
RandomTests.Execute();
|
||||
|
||||
// System.Collections
|
||||
|
|
@ -44,7 +45,7 @@ namespace Cosmos.Compiler.Tests.Bcl
|
|||
|
||||
// System.Collections.Generic
|
||||
ListTest.Execute();
|
||||
QueueTest.Execute();
|
||||
QueueTest.Execute();
|
||||
DictionaryTest.Execute();
|
||||
|
||||
// System.Text
|
||||
|
|
|
|||
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