Refactoring

This commit is contained in:
Michael Schimmel
2025-06-03 18:20:02 +02:00
parent 561a3c6bb5
commit 556690fa5e
12 changed files with 152 additions and 155 deletions
+14 -14
View File
@@ -167,7 +167,7 @@ procedure TTestMycLatch.TestSubscriber_Single_IsNotifiedWhenLatchSet;
var
latch: IMycLatch;
mockSub: TMockSubscriber;
subscription: TMycSubscription;
subscription: TState.TSubscription;
begin
latch := TLatch.Construct(1);
mockSub := TMockSubscriber.Create;
@@ -186,7 +186,7 @@ procedure TTestMycLatch.TestSubscriber_Multiple_AreNotifiedWhenLatchSet;
var
latch: IMycLatch;
mockSub1, mockSub2, mockSub3: TMockSubscriber;
sub1, sub2, sub3: TMycSubscription; // Keep subscriptions in scope
sub1, sub2, sub3: TState.TSubscription; // Keep subscriptions in scope
begin
latch := TLatch.Construct(1);
mockSub1 := TMockSubscriber.Create;
@@ -208,7 +208,7 @@ procedure TTestMycLatch.TestSubscriber_NotNotified_BeforeLatchSet;
var
latch: IMycLatch;
mockSub: TMockSubscriber;
subscription: TMycSubscription;
subscription: TState.TSubscription;
begin
latch := TLatch.Construct(2); // Count = 2
mockSub := TMockSubscriber.Create;
@@ -223,7 +223,7 @@ procedure TTestMycLatch.TestSubscriber_NotifiedOnlyOnce_AfterLatchSetAndUnadvise
var
latch: IMycLatch;
mockSub: TMockSubscriber;
subscription: TMycSubscription;
subscription: TState.TSubscription;
begin
latch := TLatch.Construct(1);
mockSub := TMockSubscriber.Create;
@@ -240,7 +240,7 @@ procedure TTestMycLatch.TestSubscribe_ToAlreadySetLatch_NotifiesImmediately;
var
latch: IMycLatch;
mockSub1, mockSub2: TMockSubscriber;
subscription1, subscription2: TMycSubscription;
subscription1, subscription2: TState.TSubscription;
begin
latch := TLatch.Construct(1); // Create with count 1
mockSub1 := TMockSubscriber.Create;
@@ -268,7 +268,7 @@ procedure TTestMycLatch.TestChaining_A_Notifies_B;
var
latchA, latchB: IMycLatch;
mockSubForB: TMockSubscriber;
subHandle_B_listens_A, subHandle_Mock_listens_B: TMycSubscription;
subHandle_B_listens_A, subHandle_Mock_listens_B: TState.TSubscription;
begin
latchA := TLatch.Construct(1);
latchB := TLatch.Construct(1); // latchB is an IMycSubscriber
@@ -293,7 +293,7 @@ procedure TTestMycLatch.TestCascade_A_Notifies_B_Notifies_C;
var
latchA, latchB, latchC: IMycLatch;
mockSubForC: TMockSubscriber;
sub_Mock_C, sub_C_B, sub_B_A: TMycSubscription;
sub_Mock_C, sub_C_B, sub_B_A: TState.TSubscription;
begin
latchA := TLatch.Construct(1);
latchB := TLatch.Construct(1);
@@ -316,7 +316,7 @@ procedure TTestMycLatch.TestChaining_B_NeedsMultipleNotifiesFromA_WithSubscriber
var
latchA, latchB: IMycLatch;
mockSubForB: TMockSubscriber;
sub_Mock_B, sub_B_A: TMycSubscription;
sub_Mock_B, sub_B_A: TState.TSubscription;
begin
// LatchA needs 2 notifies to become set. LatchB needs 1 notify to become set.
// LatchB subscribes to LatchA. So LatchB will be notified once LatchA becomes set.
@@ -345,7 +345,7 @@ procedure TTestMycLatch.TestInitiallySetLatch_NotifiesNewSubscriberImmediately;
var
latch: IMycLatch; // Will be TMycLatch.Null
mockSub: TMockSubscriber;
subscription: TMycSubscription;
subscription: TState.TSubscription;
begin
latch := TLatch.Construct(0); // Returns TMycLatch.Null which is set.
mockSub := TMockSubscriber.Create;
@@ -360,7 +360,7 @@ procedure TTestMycLatch.TestUnsubscribe_SubscriberNotNotified;
var
latch: IMycLatch;
mockSub: TMockSubscriber;
subscription: TMycSubscription;
subscription: TState.TSubscription;
begin
latch := TLatch.Construct(1);
mockSub := TMockSubscriber.Create;
@@ -379,7 +379,7 @@ procedure TTestMycLatch.TestMultipleTriggersNoSubscriber_StateCorrectForLaterSub
var
latch: IMycLatch;
mockSub: TMockSubscriber;
subscription: TMycSubscription;
subscription: TState.TSubscription;
begin
latch := TLatch.Construct(3);
@@ -402,7 +402,7 @@ procedure TTestMycLatch.TestLatchSet_ClearsSubscribers_NoFurtherNotification;
var
latch: IMycLatch;
mockSub1, mockSub2: TMockSubscriber;
subscription1, subscription2: TMycSubscription;
subscription1, subscription2: TState.TSubscription;
begin
latch := TLatch.Construct(1);
mockSub1 := TMockSubscriber.Create;
@@ -438,7 +438,7 @@ begin
var noException: Boolean := True;
try
begin // Inner block to control lifetime of 'subscription'
var subscription: TMycSubscription; // Local to this block
var subscription: TState.TSubscription; // Local to this block
subscription := latch.State.Subscribe(mockSub);
latch.Notify; // Sets the latch, mockSub is notified, UnadviseAll is called internally.
@@ -466,7 +466,7 @@ procedure TTestMycLatch.TestLatchSet_NewSubscriberToSetLatch_NotifiedImmediately
var
latch: IMycLatch;
mockSubInitial, mockSubNew: TMockSubscriber;
subscriptionInitial, subscriptionNew: TMycSubscription;
subscriptionInitial, subscriptionNew: TState.TSubscription;
begin
latch := TLatch.Construct(1);
mockSubInitial := TMockSubscriber.Create;