コード例 #1
0
        public void WriteWithArray()
        {
            const string hexBuffer = "A368496E7441727261798201026B4F626A656374417272617982A168496E7456616C756501A168496E7456616C7565026B537472696E6741727261798261616162";

            ArrayObject obj = new ArrayObject
            {
                IntArray    = new[] { 1, 2 },
                ObjectArray = new[]
                {
                    new IntObject {
                        IntValue = 1
                    },
                    new IntObject {
                        IntValue = 2
                    }
                },
                StringArray = new[] { "a", "b" }
            };

            Helper.TestWrite(obj, hexBuffer);
        }
コード例 #2
0
        public void ReadWithArray()
        {
            const string hexBuffer = "A368496E7441727261798201026B4F626A656374417272617982A168496E7456616C756501A168496E7456616C7565026B537472696E6741727261798261616162";
            ArrayObject  obj       = Helper.Read <ArrayObject>(hexBuffer);

            Assert.NotNull(obj);

            Assert.NotNull(obj.IntArray);
            Assert.Equal(2, obj.IntArray.Length);
            Assert.Equal(1, obj.IntArray[0]);
            Assert.Equal(2, obj.IntArray[1]);

            Assert.NotNull(obj.ObjectArray);
            Assert.Equal(2, obj.ObjectArray.Length);
            Assert.NotNull(obj.ObjectArray[0]);
            Assert.Equal(1, obj.ObjectArray[0].IntValue);
            Assert.NotNull(obj.ObjectArray[1]);
            Assert.Equal(2, obj.ObjectArray[1].IntValue);

            Assert.NotNull(obj.StringArray);
            Assert.Equal(2, obj.StringArray.Length);
            Assert.Equal("a", obj.StringArray[0]);
            Assert.Equal("b", obj.StringArray[1]);
        }