diff --git a/Lawo.EmberPlusSharp/Model/CollectionNode`2.cs b/Lawo.EmberPlusSharp/Model/CollectionNode`2.cs index e2fb1d8a..37f8be6b 100644 --- a/Lawo.EmberPlusSharp/Model/CollectionNode`2.cs +++ b/Lawo.EmberPlusSharp/Model/CollectionNode`2.cs @@ -62,7 +62,12 @@ internal sealed override bool ChangeVisibility(IElement child) { if (child.IsOnline) { - this.children.Add((TElement)child); + var typedChild = (TElement)child; + + if (!this.children.Contains(typedChild)) + { + this.children.Add(typedChild); + } } else { diff --git a/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs b/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs index a9831479..0c7df615 100644 --- a/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs +++ b/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs @@ -37,7 +37,10 @@ internal static bool ChangeVisibility( { if (child.IsOnline) { - dynamicChildren.Add(child); + if (!dynamicChildren.Contains(child)) + { + dynamicChildren.Add(child); + } } else { diff --git a/Lawo.EmberPlusSharp/Model/Node`1.cs b/Lawo.EmberPlusSharp/Model/Node`1.cs index 8039c23b..a7ad9e48 100644 --- a/Lawo.EmberPlusSharp/Model/Node`1.cs +++ b/Lawo.EmberPlusSharp/Model/Node`1.cs @@ -62,7 +62,10 @@ internal override bool ChangeVisibility(IElement child) { if (child.IsOnline) { - this.observableChildren.Add(child); + if (!this.observableChildren.Contains(child)) + { + this.observableChildren.Add(child); + } } else { diff --git a/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs b/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs index 7a04c789..87802b74 100644 --- a/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs +++ b/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs @@ -1393,35 +1393,6 @@ public void Bug27Test() "false")); } - /// Exposes Bug 33. - [TestMethod] - [TestCategory("Manual")] - public void Bug33Test() - { - AsyncPump.Run(async () => - { - var tcpClient = new TcpClient(); - await tcpClient.ConnectAsync("localhost", 9000); - var stream = tcpClient.GetStream(); - using (var client = new S101Client(tcpClient, stream.ReadAsync, stream.WriteAsync)) - using (var consumer = - await Consumer.CreateAsync(client, 10000, ChildrenRetrievalPolicy.DirectOnly)) - { - foreach (var child in consumer.Root.DynamicChildren) - { - var node = child as INode; - - if (node != null) - { - node.ChildrenRetrievalPolicy = ChildrenRetrievalPolicy.DirectOnly; - } - } - - await consumer.SendAsync(); - } - }); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// private static Task TestConsumerAfterFirstRequest( @@ -2003,13 +1974,16 @@ private Task DynamicChildrenRetrievalPolicyTestAsync(bool delay) consumer.AutoSendInterval = this.Random.Next(100, 5000); var root = consumer.Root; Assert.IsNull(root.Node); + Assert.AreEqual(0, ((INode)root).Children.Count); Assert.AreEqual(ChildrenRetrievalPolicy.None, root.ChildrenRetrievalPolicy); root.ChildrenRetrievalPolicy = ChildrenRetrievalPolicy.DirectOnly; await WaitForCompletion(consumer, delay); Assert.IsNotNull(root.Node); + Assert.AreEqual(1, ((INode)root).Children.Count); Assert.AreEqual(ChildrenRetrievalPolicy.None, root.Node.ChildrenRetrievalPolicy); root.Node.ChildrenRetrievalPolicy = ChildrenRetrievalPolicy.All; await WaitForCompletion(consumer, delay); + Assert.AreEqual(1, ((INode)root).Children.Count); } }, null,