TMutable
This commit is contained in:
@@ -9,14 +9,14 @@ uses
|
||||
|
||||
type
|
||||
// Helper class to mock a subscriber.
|
||||
TMockSubscriber = class(TInterfacedObject, IMycSubscriber)
|
||||
TMockSubscriber = class(TInterfacedObject, TSignal.ISubscriber)
|
||||
public
|
||||
NotifyCount: Integer;
|
||||
NotifyShouldReturn: Boolean; // Determines what this mock's Notify method returns
|
||||
WasCalled: Boolean;
|
||||
|
||||
constructor Create(AShouldReturn: Boolean = True); // Parameter name AShouldReturn for clarity
|
||||
function Notify: Boolean; // IMycSubscriber implementation.
|
||||
function Notify: Boolean; // TSignal.ISubscriber implementation.
|
||||
end;
|
||||
|
||||
[TestFixture]
|
||||
@@ -137,7 +137,7 @@ var
|
||||
returnedValueFromNotify: Boolean;
|
||||
begin
|
||||
latch := TLatch.CreateLatch(InitialCount);
|
||||
returnedValueFromNotify := latch.Notify; // This is TLatch.ILatch (as IMycSubscriber).Notify
|
||||
returnedValueFromNotify := latch.Notify; // This is TLatch.ILatch (as TSignal.ISubscriber).Notify
|
||||
|
||||
Assert.AreEqual(
|
||||
ExpectedReturn,
|
||||
@@ -282,18 +282,18 @@ var
|
||||
subHandle_B_listens_A, subHandle_Mock_listens_B: TSignal.TSubscription;
|
||||
begin
|
||||
latchA := TLatch.CreateLatch(1);
|
||||
latchB := TLatch.CreateLatch(1); // latchB is an IMycSubscriber
|
||||
latchB := TLatch.CreateLatch(1); // latchB is an TSignal.ISubscriber
|
||||
mockSubForB := TMockSubscriber.Create;
|
||||
|
||||
subHandle_Mock_listens_B := latchB.State.Subscribe(mockSubForB);
|
||||
// LatchA's state is an IMycSignal. LatchB (as IMycSubscriber) subscribes to it.
|
||||
// LatchA's state is an IMycSignal. LatchB (as TSignal.ISubscriber) subscribes to it.
|
||||
subHandle_B_listens_A := latchA.State.Subscribe(latchB);
|
||||
|
||||
Assert.IsFalse(latchA.State.IsSet, 'LatchA initially not set.');
|
||||
Assert.IsFalse(latchB.State.IsSet, 'LatchB initially not set.');
|
||||
Assert.AreEqual(0, mockSubForB.NotifyCount, 'MockSubForB initially not notified.');
|
||||
|
||||
latchA.Notify; // Call Notify on LatchA (as IMycSubscriber)
|
||||
latchA.Notify; // Call Notify on LatchA (as TSignal.ISubscriber)
|
||||
|
||||
Assert.IsTrue(latchA.State.IsSet, 'LatchA should be set after notify.');
|
||||
Assert.IsTrue(latchB.State.IsSet, 'LatchB should be set after being notified by LatchA.');
|
||||
|
||||
Reference in New Issue
Block a user