Skip to content

Commit

Permalink
Finish implementation
Browse files Browse the repository at this point in the history
More tests are needed

References #21
  • Loading branch information
andreashuber-lawo committed Apr 28, 2016
1 parent 9c8b7db commit b5c670e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Lawo.EmberPlusSharp/Glow/GlowLogInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public void ApplyPayload()
using (var dummyWriter = new EmberWriter(Stream.Null))
{
this.root.Read(emberReader, this.pendingInvocations, this.streamedParameters);
dummyWriter.WriteStartApplicationDefinedType(
GlowGlobal.Root.OuterId, GlowRootElementCollection.InnerNumber);
this.root.WriteRequest(dummyWriter, this.streamedParameters);
dummyWriter.WriteEndContainer();
this.root.SetComplete();
this.root.UpdateRetrievalState(true);
}
Expand Down
6 changes: 5 additions & 1 deletion Lawo.EmberPlusSharp/Model/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Lawo.EmberPlusSharp.Model
using System.Threading.Tasks;

using Ember;
using Glow;
using IO;
using S101;

Expand Down Expand Up @@ -466,7 +467,10 @@ private bool WriteRequest(out MemoryStream stream)
using (stream = new MemoryStream())
using (var writer = new EmberWriter(stream))
{
return this.root.WriteRequest(writer, this.streamedParameters);
writer.WriteStartApplicationDefinedType(GlowGlobal.Root.OuterId, GlowRootElementCollection.InnerNumber);
var result = this.root.WriteRequest(writer, this.streamedParameters);
writer.WriteEndContainer();
return result;
}
}

Expand Down
9 changes: 7 additions & 2 deletions Lawo.EmberPlusSharp/Model/NodeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public ChildrenRetrievalPolicy ChildrenRetrievalPolicy
}

this.SetRetrieveDetailsChangeStatus(() => this.SetValue(ref this.childrenRetrievalPolicy, value));

if (this.RetrieveDetailsChangeStatus != RetrieveDetailsChangeStatus.Unchanged)
{
this.HasChanges = true;
}
}
}
}
Expand Down Expand Up @@ -134,9 +139,9 @@ internal void WriteChangesCollection(EmberWriter writer, IInvocationCollection p
{
if (this.children.Count == 0)
{
if (this.RetrieveDetails && (this.RetrieveDetailsChangeStatus == RetrieveDetailsChangeStatus.Changed))
if (this.RetrieveDetails && (this.RetrieveDetailsChangeStatus != RetrieveDetailsChangeStatus.Unchanged))
{
this.WriteCommandCollection(writer, GlowCommandNumber.GetDirectory, RetrievalState.RequestSent);
this.WriteRequest(writer, null);
}
}
else
Expand Down
5 changes: 1 addition & 4 deletions Lawo.EmberPlusSharp/Model/Root.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ internal sealed override bool ReadChildrenCore(EmberReader reader)
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")]
internal sealed override bool WriteRequest(EmberWriter writer, IStreamedParameterCollection streamedParameters)
{
writer.WriteStartApplicationDefinedType(GlowGlobal.Root.OuterId, GlowRootElementCollection.InnerNumber);
var result = this.WriteCommandCollection(writer, streamedParameters);
writer.WriteEndContainer();
return result;
return this.WriteCommandCollection(writer, streamedParameters);
}

[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")]
Expand Down
31 changes: 28 additions & 3 deletions Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,34 @@ public void ChildrenRetrievalPolicyTest()
AsyncPump.Run(
async () =>
{
await ChildrenRetrievalPolicyTestCoreAsync(ChildrenRetrievalPolicy.None, "ChildrenRetrievalPolicyLog1.xml");
await ChildrenRetrievalPolicyTestCoreAsync(ChildrenRetrievalPolicy.DirectOnly, "ChildrenRetrievalPolicyLog2.xml");
await ChildrenRetrievalPolicyTestCoreAsync(ChildrenRetrievalPolicy.All, "ChildrenRetrievalPolicyLog3.xml");
await ChildrenRetrievalPolicyTestCoreAsync(
ChildrenRetrievalPolicy.None, "ChildrenRetrievalPolicyLog1.xml");
await ChildrenRetrievalPolicyTestCoreAsync(
ChildrenRetrievalPolicy.DirectOnly, "ChildrenRetrievalPolicyLog2.xml");
await ChildrenRetrievalPolicyTestCoreAsync(
ChildrenRetrievalPolicy.All, "ChildrenRetrievalPolicyLog3.xml");
await TestWithRobot<ModelPayloads>(
async client =>
{
using (var consumer = await Consumer<EmptyNodeRoot>.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");
});
}

Expand Down

0 comments on commit b5c670e

Please sign in to comment.