Implementing first "strategy" for proof of concept
This commit is contained in:
@@ -74,8 +74,8 @@ end;
|
||||
|
||||
procedure TMycTestNotifierTests.Setup;
|
||||
begin
|
||||
FNotifier.Create;
|
||||
// FNotifier's internal FFirst is now 1 (unlocked, not finalized)
|
||||
FNotifier := Default(TMycNotifyList<IMyTestInterface>);
|
||||
end;
|
||||
|
||||
procedure TMycTestNotifierTests.TearDown;
|
||||
@@ -92,7 +92,7 @@ procedure TMycTestNotifierTests.Test01_DestroyExecutesWithoutErrors;
|
||||
begin
|
||||
// This call is expected to succeed without raising EAssertionFailed or other exceptions
|
||||
// if TMycNotifyList.Destroy is implemented correctly.
|
||||
FNotifier.Destroy;
|
||||
FNotifier.Finalize;
|
||||
Assert.IsTrue(True, 'FNotifier.Destroy completed without raising an exception.');
|
||||
end;
|
||||
|
||||
@@ -102,11 +102,11 @@ end;
|
||||
procedure TMycTestNotifierTests.Test02_NotifyOnFinalizedLockedEmptyListExecutesWithoutErrors;
|
||||
var
|
||||
predicateCallCount: Integer;
|
||||
dummyPredicate: TPredicate<IMyTestInterface>;
|
||||
dummyPredicate: TMycNotifyList<IMyTestInterface>.TNotifyProc;
|
||||
begin
|
||||
predicateCallCount := 0;
|
||||
dummyPredicate :=
|
||||
function(Item: IMyTestInterface): Boolean
|
||||
function(const Item: IMyTestInterface): Boolean
|
||||
begin
|
||||
Inc(predicateCallCount);
|
||||
Result := True;
|
||||
@@ -209,7 +209,7 @@ begin
|
||||
|
||||
itemsProcessedCount := 0;
|
||||
FNotifier.Notify(
|
||||
function(Item: IMyTestInterface): Boolean
|
||||
function(const Item: IMyTestInterface): Boolean
|
||||
begin
|
||||
Inc(itemsProcessedCount);
|
||||
TMyTestReceiver(Item).Foo;
|
||||
@@ -229,7 +229,7 @@ begin
|
||||
itemsProcessedCount := 0;
|
||||
|
||||
FNotifier.Notify(
|
||||
function(Item: IMyTestInterface): Boolean
|
||||
function(const Item: IMyTestInterface): Boolean
|
||||
begin
|
||||
Inc(itemsProcessedCount);
|
||||
TMyTestReceiver(Item).Foo;
|
||||
|
||||
@@ -213,7 +213,7 @@ begin
|
||||
// if not FOwnerFixture.FNotifier.IsFinalized then // Don't notify if finalized
|
||||
begin
|
||||
FOwnerFixture.FNotifier.Notify(
|
||||
function(Item: IMyStressTestInterface): Boolean
|
||||
function(const Item: IMyStressTestInterface): Boolean
|
||||
begin
|
||||
Item.Foo(FThreadID); // Pass ThreadID as notification type for context
|
||||
Result := True; // Keep item
|
||||
@@ -255,7 +255,6 @@ end;
|
||||
procedure TMycNotifierChaosStressTests.Setup;
|
||||
begin
|
||||
Randomize; // Initialize random number generator
|
||||
FNotifier.Create;
|
||||
FAllReceiversCreated := TList<IMyStressTestInterface>.Create;
|
||||
FCriticalSectionForList := TCriticalSection.Create;
|
||||
FNextReceiverInstanceID := 0;
|
||||
@@ -359,7 +358,7 @@ begin
|
||||
// if not FNotifier.IsFinalized then
|
||||
begin
|
||||
FNotifier.Notify(
|
||||
function(Item: IMyStressTestInterface): Boolean
|
||||
function(const Item: IMyStressTestInterface): Boolean
|
||||
begin
|
||||
actualLiveReceiversInNotifier.Add(Item);
|
||||
Result := True;
|
||||
|
||||
@@ -154,7 +154,6 @@ end;
|
||||
procedure TMycNotifierThreadingTests.Setup;
|
||||
begin
|
||||
Randomize;
|
||||
FNotifier.Create;
|
||||
FReceiverMasterList := TList<IMyTestInterface>.Create;
|
||||
end;
|
||||
|
||||
@@ -256,7 +255,7 @@ begin
|
||||
FNotifier.Lock;
|
||||
try
|
||||
FNotifier.Notify(
|
||||
function(Item: IMyTestInterface): Boolean
|
||||
function(const Item: IMyTestInterface): Boolean
|
||||
begin
|
||||
Inc(currentNotifyCount);
|
||||
Result := True; // Keep item in the Notifier
|
||||
@@ -288,7 +287,7 @@ begin
|
||||
FNotifier.Lock;
|
||||
try
|
||||
FNotifier.Notify(
|
||||
function(Item: IMyTestInterface): Boolean
|
||||
function(const Item: IMyTestInterface): Boolean
|
||||
begin
|
||||
Inc(currentNotifyCount);
|
||||
Result := True;
|
||||
|
||||
Reference in New Issue
Block a user