public void GetLeafFieldValueBytes() { Message msg = MessagesProvider.GetMessage(); ParserContext pc = new ParserContext(ParserContext.DefaultBufferSize); FormatterContext fc = new FormatterContext(FormatterContext.DefaultBufferSize); ParentMessageExpression pme = new ParentMessageExpression( new MessageExpression(52)); // Parent of a message without one. try { pme.GetLeafFieldValueString(ref fc, msg); Assert.Fail(); } catch (ExpressionEvaluationException) { } // Passing null message (as parameter and in the contexts). try { pme.GetLeafFieldValueString(ref fc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } try { pme.GetLeafFieldValueString(ref pc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } msg = msg[62].Value as Message; Message anotherMsg = MessagesProvider.GetAnotherMessage(); anotherMsg = anotherMsg[61].Value as Message; Assert.IsTrue(MessagesProvider.CompareByteArrays(pme.GetLeafFieldValueBytes(ref fc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); fc.CurrentMessage = anotherMsg; Assert.IsTrue(MessagesProvider.CompareByteArrays(pme.GetLeafFieldValueBytes(ref fc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); Assert.IsTrue(MessagesProvider.CompareByteArrays(pme.GetLeafFieldValueBytes(ref fc, null), new byte[] { 0x55, 0x60, 0x65, 0x70, 0x75, 0x80, 0x85, 0x90 })); Assert.IsTrue(MessagesProvider.CompareByteArrays(pme.GetLeafFieldValueBytes(ref pc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); pc.CurrentMessage = anotherMsg; Assert.IsTrue(MessagesProvider.CompareByteArrays(pme.GetLeafFieldValueBytes(ref pc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); Assert.IsTrue(MessagesProvider.CompareByteArrays(pme.GetLeafFieldValueBytes(ref pc, null), new byte[] { 0x55, 0x60, 0x65, 0x70, 0x75, 0x80, 0x85, 0x90 })); }
public void GetLeafFieldNumber() { MessageExpression me = new MessageExpression(4); ParentMessageExpression pme = new ParentMessageExpression(me); Assert.IsTrue(pme.GetLeafFieldNumber() == 4); me = new MessageExpression(11); pme.MessageExpression = me; Assert.IsTrue(pme.GetLeafFieldNumber() == 11); me.FieldNumber = 5; Assert.IsTrue(pme.GetLeafFieldNumber() == 5); }
public void GetLeafMessage() { Message msg = MessagesProvider.GetMessage(); ParserContext pc = new ParserContext(ParserContext.DefaultBufferSize); FormatterContext fc = new FormatterContext(FormatterContext.DefaultBufferSize); ParentMessageExpression pme = new ParentMessageExpression( new MessageExpression()); // Parent of a message without one. try { pme.GetLeafMessage(ref fc, msg); Assert.Fail(); } catch (ExpressionEvaluationException) { } // Passing null message (as parameter and in the contexts). try { pme.GetLeafMessage(ref fc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } try { pme.GetLeafMessage(ref pc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } msg = msg[61].Value as Message; Message anotherMsg = MessagesProvider.GetAnotherMessage(); anotherMsg = anotherMsg[62].Value as Message; Assert.IsTrue((pme.GetLeafMessage(ref fc, msg)[41].Value as string) == "TEST1"); fc.CurrentMessage = anotherMsg; Assert.IsTrue((pme.GetLeafMessage(ref fc, msg)[41].Value as string) == "TEST1"); Assert.IsTrue((pme.GetLeafMessage(ref fc, null)[41].Value as string) == "TEST2"); Assert.IsTrue((pme.GetLeafMessage(ref pc, msg)[41].Value as string) == "TEST1"); pc.CurrentMessage = anotherMsg; Assert.IsTrue((pme.GetLeafMessage(ref pc, msg)[41].Value as string) == "TEST1"); Assert.IsTrue((pme.GetLeafMessage(ref pc, null)[41].Value as string) == "TEST2"); }
public void InstantiationAndProperties() { ParentMessageExpression pme = new ParentMessageExpression(); Assert.IsNull(pme.MessageExpression); MessageExpression me = new MessageExpression(); pme = new ParentMessageExpression(me); Assert.IsTrue(pme.MessageExpression == me); MessageExpression fve2 = new MessageExpression(); pme.MessageExpression = fve2; Assert.IsTrue(pme.MessageExpression == fve2); }