diff --git a/Lawo.EmberPlusSharp/Model/INode.cs b/Lawo.EmberPlusSharp/Model/INode.cs
index b794f632..153e1675 100644
--- a/Lawo.EmberPlusSharp/Model/INode.cs
+++ b/Lawo.EmberPlusSharp/Model/INode.cs
@@ -22,8 +22,10 @@ public interface INode : IElementWithSchemas
/// .
/// Attempted to set a value that is not equal to one of the named
/// constants of .
- /// Setting this property prompts the consumer to automatically retrieve children according to the new
- /// value. To wait for the children to be retrieved, the result of a call to
+ /// Setting this property prompts the consumer to retrieve direct and indirect children according to
+ /// the new value. The retrieval starts automatically when
+ /// Consumer<TRoot>.AutoSendInterval elapses. To
+ /// explicitly wait for the children to be retrieved, the result of a call to
/// .
ChildrenRetrievalPolicy ChildrenRetrievalPolicy { get; set; }
diff --git a/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs b/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
index fd391052..55d0bf74 100644
--- a/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
+++ b/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
@@ -455,34 +455,14 @@ public void ChildrenRetrievalPolicyTest()
AsyncPump.Run(
async () =>
{
- await ChildrenRetrievalPolicyTestCoreAsync(
+ await StaticChildrenRetrievalPolicyTestAsync(
ChildrenRetrievalPolicy.None, "ChildrenRetrievalPolicyLog1.xml");
- await ChildrenRetrievalPolicyTestCoreAsync(
+ await StaticChildrenRetrievalPolicyTestAsync(
ChildrenRetrievalPolicy.DirectOnly, "ChildrenRetrievalPolicyLog2.xml");
- await ChildrenRetrievalPolicyTestCoreAsync(
+ await StaticChildrenRetrievalPolicyTestAsync(
ChildrenRetrievalPolicy.All, "ChildrenRetrievalPolicyLog3.xml");
- await TestWithRobot(
- async client =>
- {
- using (var consumer = await Consumer.CreateAsync(
- client, Timeout.Infinite, ChildrenRetrievalPolicy.None))
- {
- var root = consumer.Root;
- Assert.IsNull(root.Node);
- Assert.AreEqual(ChildrenRetrievalPolicy.None, root.ChildrenRetrievalPolicy);
- root.ChildrenRetrievalPolicy = ChildrenRetrievalPolicy.DirectOnly;
- await consumer.SendAsync();
- Assert.IsNotNull(root.Node);
- Assert.AreEqual(ChildrenRetrievalPolicy.None, root.Node.ChildrenRetrievalPolicy);
- root.Node.ChildrenRetrievalPolicy = ChildrenRetrievalPolicy.All;
- await consumer.SendAsync();
- }
- },
- null,
- null,
- GlowTypes.Instance,
- false,
- "ChildrenRetrievalPolicyLog3.xml");
+ await DynamicChildrenRetrievalPolicyTestAsync(false);
+ await DynamicChildrenRetrievalPolicyTestAsync(true);
});
}
@@ -1613,7 +1593,7 @@ private static void AssertAccess(RecursiveFieldNode node)
}
}
- private static Task ChildrenRetrievalPolicyTestCoreAsync(ChildrenRetrievalPolicy policy, string logName)
+ private static Task StaticChildrenRetrievalPolicyTestAsync(ChildrenRetrievalPolicy policy, string logName)
{
return TestWithRobot(
async client =>
@@ -1659,6 +1639,38 @@ private static Task ChildrenRetrievalPolicyTestCoreAsync(ChildrenRetrievalPolicy
logName);
}
+ private Task DynamicChildrenRetrievalPolicyTestAsync(bool delay)
+ {
+ return TestWithRobot(
+ async client =>
+ {
+ using (var consumer = await Consumer.CreateAsync(
+ client, Timeout.Infinite, ChildrenRetrievalPolicy.None))
+ {
+ consumer.AutoSendInterval = this.Random.Next(100, 5000);
+ var root = consumer.Root;
+ Assert.IsNull(root.Node);
+ Assert.AreEqual(ChildrenRetrievalPolicy.None, root.ChildrenRetrievalPolicy);
+ root.ChildrenRetrievalPolicy = ChildrenRetrievalPolicy.DirectOnly;
+ await WaitForCompletion(consumer, delay);
+ Assert.IsNotNull(root.Node);
+ Assert.AreEqual(ChildrenRetrievalPolicy.None, root.Node.ChildrenRetrievalPolicy);
+ root.Node.ChildrenRetrievalPolicy = ChildrenRetrievalPolicy.All;
+ await WaitForCompletion(consumer, delay);
+ }
+ },
+ null,
+ null,
+ GlowTypes.Instance,
+ false,
+ "ChildrenRetrievalPolicyLog3.xml");
+ }
+
+ private static Task WaitForCompletion(Consumer consumer, bool delay)
+ {
+ return delay ? Task.Delay(consumer.AutoSendInterval + 500) : consumer.SendAsync();
+ }
+
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Objects are disposed within the called method.")]
private static Task TestWithRobot(
Func, Task> testCallback, bool log, string logXmlName, params object[] args) where TRoot : Root