public void CheckElementsCorrectForSubMessage() { var context = new FudgeContext(); var msg = context.NewMessage(); var subMsg = context.NewMessage(); msg.Add("sub", subMsg); subMsg.Add("Test", "Bob"); var bytes = context.ToByteArray(msg); var stream = new MemoryStream(bytes); var reader = new FudgeEncodedStreamReader(context, stream); Assert.True(reader.HasNext); Assert.Equal(FudgeStreamElement.MessageStart, reader.MoveNext()); Assert.True(reader.HasNext); Assert.Equal(FudgeStreamElement.SubmessageFieldStart, reader.MoveNext()); Assert.True(reader.HasNext); Assert.Equal(FudgeStreamElement.SimpleField, reader.MoveNext()); Assert.True(reader.HasNext); Assert.Equal(FudgeStreamElement.SubmessageFieldEnd, reader.MoveNext()); Assert.True(reader.HasNext); Assert.Equal(FudgeStreamElement.MessageEnd, reader.MoveNext()); Assert.False(reader.HasNext); }
protected FudgeMsgEnvelope CycleMessage(FudgeContext context, FudgeMsg msg) { FudgeStreamParser parser = new FudgeStreamParser(context); byte[] msgAsBytes = context.ToByteArray(msg); return(parser.Parse(new MemoryStream(msgAsBytes))); }
protected static FudgeMsg CycleMessage(FudgeMsg msg) //throws IOException { byte[] content = fudgeContext.ToByteArray(msg); // Double-check the size calc was right Assert.Equal(content.Length, new FudgeMsgEnvelope(msg).ComputeSize(null)); MemoryStream stream2 = new MemoryStream(content); FudgeMsgEnvelope outputMsgEnvelope = fudgeContext.Deserialize(stream2); Assert.NotNull(outputMsgEnvelope); Assert.NotNull(outputMsgEnvelope.Message); return(outputMsgEnvelope.Message); }
public void CheckEndOfStreamWithoutHasNext() { // Same as CheckElementsCorrectForSimpleMessage but without using HasNext var context = new FudgeContext(); var msg = context.NewMessage(); msg.Add("Test", "Bob"); var bytes = context.ToByteArray(msg); var stream = new MemoryStream(bytes); var reader = new FudgeEncodedStreamReader(context, stream); Assert.Equal(FudgeStreamElement.MessageStart, reader.MoveNext()); Assert.Equal(FudgeStreamElement.SimpleField, reader.MoveNext()); Assert.Equal(FudgeStreamElement.MessageEnd, reader.MoveNext()); Assert.Equal(FudgeStreamElement.NoElement, reader.MoveNext()); Assert.Equal(FudgeStreamElement.NoElement, reader.MoveNext()); }
protected FudgeMsgEnvelope CycleMessage(FudgeContext context, FudgeMsg msg) { FudgeStreamParser parser = new FudgeStreamParser(context); byte[] msgAsBytes = context.ToByteArray(msg); return parser.Parse(new MemoryStream(msgAsBytes)); }