Skip to content

Commit

Permalink
Made tests more robust by using GetConsumingEnumerable which blocks i…
Browse files Browse the repository at this point in the history
…ndefinitely.
  • Loading branch information
saurla committed Apr 23, 2024
1 parent 60689c9 commit 9584568
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Opc.Ua.Core.Tests.Stack.State
public class NodeStateCollectionConcurrencyTests
{
[Test]
[CancelAfter(10000)]
public void NodeStateReferencesCollectionConcurrencyTest()
{
var testNodeState = new AnalogUnitRangeState(null);
Expand Down Expand Up @@ -56,7 +57,7 @@ public void NodeStateReferencesCollectionConcurrencyTest()
});

while (referenceTargets.TryTake(out ExpandedNodeId target, TimeSpan.FromSeconds(1)))
foreach (var target in referenceTargets.GetConsumingEnumerable())
{
var removeReferenceSuccess = testNodeState.RemoveReference(ReferenceTypeIds.HasComponent, false, target);
Assert.IsTrue(removeReferenceSuccess);
Expand All @@ -72,6 +73,7 @@ public void NodeStateReferencesCollectionConcurrencyTest()
}

[Test]
[CancelAfter(10000)]
public void NodeStateNotifiersCollectionConcurrencyTest()
{
var serviceMessageContext = new ServiceMessageContext();
Expand Down Expand Up @@ -120,7 +122,7 @@ public void NodeStateNotifiersCollectionConcurrencyTest()
});

while (notifierTargets.TryTake(out NodeState target, TimeSpan.FromSeconds(1)))
foreach(var target in notifierTargets.GetConsumingEnumerable())
{
testNodeState.RemoveNotifier(systemContext, target, false);
}
Expand All @@ -135,6 +137,7 @@ public void NodeStateNotifiersCollectionConcurrencyTest()
}

[Test]
[CancelAfter(10000)]
public void NodeStateChildrenCollectionConcurrencyTest()
{
var serviceMessageContext = new ServiceMessageContext();
Expand Down Expand Up @@ -183,7 +186,7 @@ public void NodeStateChildrenCollectionConcurrencyTest()
});

while (childrenCollection.TryTake(out BaseInstanceState child, TimeSpan.FromSeconds(1)))
foreach (var child in childrenCollection.GetConsumingEnumerable())
{
testNodeState.RemoveChild(child);
}
Expand Down

0 comments on commit 9584568

Please sign in to comment.