Skip to content

Commit

Permalink
Fix associated bug and move exposure code into regular test
Browse files Browse the repository at this point in the history
Closes #33
  • Loading branch information
andreashuber-lawo committed Feb 8, 2017
1 parent 27ed394 commit 72cbc74
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
7 changes: 6 additions & 1 deletion Lawo.EmberPlusSharp/Model/CollectionNode`2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
5 changes: 4 additions & 1 deletion Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ internal static bool ChangeVisibility(
{
if (child.IsOnline)
{
dynamicChildren.Add(child);
if (!dynamicChildren.Contains(child))
{
dynamicChildren.Add(child);
}
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion Lawo.EmberPlusSharp/Model/Node`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
32 changes: 3 additions & 29 deletions Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,35 +1393,6 @@ public void Bug27Test()
"false"));
}

/// <summary>Exposes <see href="https://github.com/Lawo/ember-plus-sharp/issues/33">Bug 33</see>.</summary>
[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<EmptyDynamicRoot>.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<TRoot>(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 72cbc74

Please sign in to comment.