예제 #1
0
        public void TestNullsNoInitialValue()
        {
            var             field    = new Scalar(new QName("mostlyNull"), FastType.I32, Operator.Default, ScalarValue.Undefined, true);
            MessageTemplate template = Template(field);
            FastEncoder     encoder  = Encoder(template);

            var message = (Message)template.CreateValue(null);

            TestUtil.AssertBitVectorEquals("11000000 10000001", encoder.Encode(message));
            TestUtil.AssertBitVectorEquals("10000000", encoder.Encode(message));
        }
예제 #2
0
        public void TestNullsWithInitialValue()
        {
            var             field    = new Scalar(new QName("sometimesNull"), FastType.I32, Operator.Default, new IntegerValue(10), true);
            MessageTemplate template = Template(field);
            FastEncoder     encoder  = Encoder(template);

            var message = (Message)template.CreateValue(null);

            TestUtil.AssertBitVectorEquals("11100000 10000001 10000000", encoder.Encode(message));
            TestUtil.AssertBitVectorEquals("10100000 10000000", encoder.Encode(message));
            message.SetInteger(1, 10);
            TestUtil.AssertBitVectorEquals("10000000", encoder.Encode(message));
        }
예제 #3
0
        public void TestNullValueDoesntAlterDictionary()
        {
            var             copyField    = new Scalar(new QName("value"), FastType.I32, Operator.Copy, new IntegerValue(10), true);
            var             field        = new Scalar(new QName("value"), FastType.I32, Operator.Default, new IntegerValue(10), true);
            MessageTemplate copyTemplate = Template(copyField);
            MessageTemplate template     = Template(field);
            var             context      = new Context();
            var             encoder      = new FastEncoder(context);

            encoder.RegisterTemplate(1, template);
            encoder.RegisterTemplate(2, copyTemplate);
            var message = (Message)copyTemplate.CreateValue(null);

            message.SetInteger(1, 11);
            encoder.Encode(message);
            Assert.AreEqual(11, context.Lookup("global", copyTemplate, new QName("value")).ToInt());
            message = (Message)template.CreateValue(null);
            encoder.Encode(message);
            Assert.AreEqual(11, context.Lookup("global", copyTemplate, new QName("value")).ToInt());
        }