Test Refactoring of signals

This commit is contained in:
Michael Schimmel
2025-06-05 22:11:54 +02:00
parent c9817ca200
commit e06a023742
17 changed files with 528 additions and 774 deletions
+14 -14
View File
@@ -86,10 +86,10 @@ end;
procedure TMycTaskFactoryTests.TestRunImmediateJob;
var
jobExecuted: Boolean;
jobCompletedLatch: IMycLatch;
jobCompletedLatch: IMycEvent;
begin
jobExecuted := False;
jobCompletedLatch := TLatch.Construct(1); // Changed from Signals.CreateLatch
jobCompletedLatch := TEvent.CreateLatch(1); // Changed from Signals.CreateLatch
FFactory
.Run(
@@ -107,11 +107,11 @@ end;
procedure TMycTaskFactoryTests.TestRunDelayedJobExecutesAfterAllNotifies;
var
jobExecuted: Boolean;
jobCompletedLatch: IMycLatch;
jobCompletedLatch: IMycEvent;
subscriber: IMycSubscriber;
begin
jobExecuted := False;
jobCompletedLatch := TLatch.Construct(1); // Changed from Signals.CreateLatch
jobCompletedLatch := TEvent.CreateLatch(1); // Changed from Signals.CreateLatch
subscriber :=
FFactory.Run(
@@ -124,7 +124,7 @@ begin
Assert.IsNotNull(subscriber, 'Run should return a subscriber for delayed job');
// Use TMycLatch.Null for comparison
Assert.AreNotEqual<IMycSubscriber>(TLatch.Null, subscriber, 'Subscriber should not be TMycLatch.Null for StartCount > 0');
Assert.AreNotEqual<IMycSubscriber>(TEvent.Null, subscriber, 'Subscriber should not be TMycLatch.Null for StartCount > 0');
subscriber.Notify;
@@ -134,11 +134,11 @@ end;
procedure TMycTaskFactoryTests.TestWaitForAlreadySetState;
var
alreadySetLatch: IMycLatch;
alreadySetLatch: IMycEvent;
startTime, endTime: Cardinal;
begin
// TMycLatch.CreateLatch(0) will return TMycLatch.Null
alreadySetLatch := TLatch.Construct(0); // Changed from Signals.CreateLatch
alreadySetLatch := TEvent.CreateLatch(0); // Changed from Signals.CreateLatch
Assert.IsTrue(alreadySetLatch.State.IsSet, 'Latch should be initially set');
startTime := TThread.GetTickCount;
@@ -152,11 +152,11 @@ procedure TMycTaskFactoryTests.TestThreadInfoMethods;
var
inMainThreadInJob: Boolean;
inWorkerThreadInJob: Boolean;
jobDoneLatch: IMycLatch;
jobDoneLatch: IMycEvent;
begin
inMainThreadInJob := True;
inWorkerThreadInJob := False;
jobDoneLatch := TLatch.Construct(1); // Changed from Signals.CreateLatch
jobDoneLatch := TEvent.CreateLatch(1); // Changed from Signals.CreateLatch
Assert.IsTrue(FFactory.InMainThread, 'Test method itself should be in main thread');
Assert.IsFalse(FFactory.InWorkerThread, 'Test method itself should not be in a factory worker thread');
@@ -178,9 +178,9 @@ end;
procedure TMycTaskFactoryTests.TestExceptionPropagationFromJob;
var
jobDoneLatch: IMycLatch;
jobDoneLatch: IMycEvent;
begin
jobDoneLatch := TLatch.Construct(1);
jobDoneLatch := TEvent.CreateLatch(1);
FFactory.EnqueueJob(
procedure
@@ -222,12 +222,12 @@ end;
procedure TMycTaskFactoryTests.TestWaitForInWorkerThreadRaisesException;
var
exceptionCaughtInJob: Boolean;
jobDoneLatch: IMycLatch;
jobDoneLatch: IMycEvent;
dummyStateToWaitFor: IMycState;
begin
exceptionCaughtInJob := False;
jobDoneLatch := TLatch.Construct(1);
dummyStateToWaitFor := TLatch.Construct(1).State;
jobDoneLatch := TEvent.CreateLatch(1);
dummyStateToWaitFor := TEvent.CreateLatch(1).State;
FFactory.EnqueueJob(
procedure