Example #1
0
        public void TestSimpleCompositeParsers()
        {
            string configXml = @"/Resources/composites.xml";
            MessageFactory <IsoMessage> mfact = Config(configXml);
            IsoMessage m = mfact.ParseMessage("01000040000000000000016one  03two12345.".GetSbytes(), 0);

            Assert.NotNull(m);
            CompositeField f = (CompositeField)m.GetObjectValue(10);

            Assert.NotNull(f);
            Assert.Equal(4, f.Values.Count);
            Assert.Equal("one  ", f.GetObjectValue(0));
            Assert.Equal("two", f.GetObjectValue(1));
            Assert.Equal("12345", f.GetObjectValue(2));
            Assert.Equal(".", f.GetObjectValue(3));

            m = mfact.ParseMessage("01000040000000000000018ALPHA05LLVAR12345X".GetSbytes(), 0);
            Assert.NotNull(m);
            Assert.True(m.HasField(10));
            f = (CompositeField)m.GetObjectValue(10);
            Assert.NotNull(f.GetField(0));
            Assert.NotNull(f.GetField(1));
            Assert.NotNull(f.GetField(2));
            Assert.NotNull(f.GetField(3));
            Assert.Null(f.GetField(4));
            Assert.Equal("ALPHA", f.GetObjectValue(0));
            Assert.Equal("LLVAR", f.GetObjectValue(1));
            Assert.Equal("12345", f.GetObjectValue(2));
            Assert.Equal("X", f.GetObjectValue(3));
        }
Example #2
0
        public void TestNestedCompositeParser()
        {
            string configXml = @"/Resources/composites.xml";
            MessageFactory <IsoMessage> mfact = Config(configXml);
            IsoMessage m = mfact.ParseMessage("01010040000000000000019ALPHA11F1F205F03F4X".GetSbytes(), 0);

            Assert.NotNull(m);
            Assert.True(m.HasField(10));
            CompositeField f = (CompositeField)m.GetObjectValue(10);

            Assert.NotNull(f.GetField(0));
            Assert.NotNull(f.GetField(1));
            Assert.NotNull(f.GetField(2));
            Assert.Null(f.GetField(3));
            Assert.Equal("ALPHA", f.GetObjectValue(0));
            Assert.Equal("X", f.GetObjectValue(2));
            f = (CompositeField)f.GetObjectValue(1);
            Assert.Equal("F1", f.GetObjectValue(0));
            Assert.Equal("F2", f.GetObjectValue(1));
            f = (CompositeField)f.GetObjectValue(2);
            Assert.Equal("F03", f.GetObjectValue(0));
            Assert.Equal("F4", f.GetObjectValue(1));
        }
Example #3
0
        public void TestExtendCompositeWithSameField()
        {
            string configXml = @"/Resources/issue47.xml";
            MessageFactory <IsoMessage> mfact = Config(configXml);

            string m200 = "02001000000000000004000000100000013ABCDEFGHIJKLM";

            IsoMessage isoMessage = mfact.ParseMessage(m200.GetSbytes(), 0);

            // check field num 4
            IsoValue field4 = isoMessage.GetField(4);

            Assert.Equal(IsoType.AMOUNT, field4.Type);
            Assert.Equal(IsoType.AMOUNT.Length(), field4.Length);

            // check nested field num 4 from composite field 62
            CompositeField compositeField62 = (CompositeField)isoMessage.GetField(62).Value;
            IsoValue       nestedField4     = compositeField62.GetField(0); // first in list

            Assert.Equal(IsoType.ALPHA, nestedField4.Type);
            Assert.Equal(13, nestedField4.Length);
        }