mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-13 19:55:02 +00:00
Begin adding tests for ThreadingUtils and SafeCriticalSection
This commit is contained in:
41
ICD.Common.Utils.Tests/ThreadingUtilsTest.cs
Normal file
41
ICD.Common.Utils.Tests/ThreadingUtilsTest.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ICD.Common.Utils.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class ThreadingUtilsTest
|
||||
{
|
||||
[Test]
|
||||
public void Sleep()
|
||||
{
|
||||
DateTime now = IcdEnvironment.GetLocalTime();
|
||||
ThreadingUtils.Sleep(1000);
|
||||
DateTime now2 = IcdEnvironment.GetLocalTime();
|
||||
|
||||
Assert.AreEqual(1000, (now2 - now).TotalMilliseconds, 100);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SafeInvokeTest()
|
||||
{
|
||||
bool result = false;
|
||||
ThreadingUtils.SafeInvoke(() => result = true);
|
||||
|
||||
Assert.IsFalse(result);
|
||||
ThreadingUtils.Sleep(1000);
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SafeInvokeParamTest()
|
||||
{
|
||||
bool result = false;
|
||||
ThreadingUtils.SafeInvoke(p => result = p, true);
|
||||
|
||||
Assert.IsFalse(result);
|
||||
ThreadingUtils.Sleep(1000);
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user