Esempio n. 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));
        }
Esempio n. 2
0
        public void TestSimpleCompositeTemplate()
        {
            string configXml = @"/Resources/composites.xml";
            MessageFactory <IsoMessage> mfact = Config(configXml);
            IsoMessage m = mfact.NewMessage(0x100);

            //Simple composite
            Assert.NotNull(m);
            Assert.False(m.HasField(1));
            Assert.False(m.HasField(2));
            Assert.False(m.HasField(3));
            Assert.False(m.HasField(4));
            CompositeField f = (CompositeField)m.GetObjectValue(10);

            Assert.NotNull(f);
            Assert.Equal(f.GetObjectValue(0), "abcde");
            Assert.Equal(f.GetObjectValue(1), "llvar");
            Assert.Equal(f.GetObjectValue(2), "12345");
            Assert.Equal(f.GetObjectValue(3), "X");
            Assert.False(m.HasField(4));
        }
Esempio n. 3
0
        private void NestedCompositeTemplate(int type, int fnum)
        {
            string configXml = @"/Resources/composites.xml";
            MessageFactory <IsoMessage> mfact = Config(configXml);
            IsoMessage m = mfact.NewMessage(type);

            Assert.NotNull(m);
            Assert.False(m.HasField(1));
            Assert.False(m.HasField(2));
            Assert.False(m.HasField(3));
            Assert.False(m.HasField(4));
            CompositeField f = (CompositeField)m.GetObjectValue(fnum);

            Assert.Equal(f.GetObjectValue(0), "fghij");
            Assert.Equal(f.GetObjectValue(2), "67890");
            Assert.Equal(f.GetObjectValue(3), "Y");
            f = (CompositeField)f.GetObjectValue(1);
            Assert.Equal(f.GetObjectValue(0), "KL");
            Assert.Equal(f.GetObjectValue(1), "mn");
            f = (CompositeField)f.GetObjectValue(2);
            Assert.Equal(f.GetObjectValue(0), "123");
            Assert.Equal(f.GetObjectValue(1), "45");
        }
Esempio n. 4
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));
        }