Пример #1
0
        public void TestSerializationByValueNullMembers()
        {
            NullMembers obj = new NullMembers(null, null, 12345678);

            byte[]      buffer = Protocol.Serialize(obj);
            NullMembers obj2   = (NullMembers)Protocol.Deserialize(buffer);

            Assert.That(obj2.nullMember1, Is.EqualTo(obj.nullMember1));
            Assert.That(obj2.nullMember2, Is.EqualTo(obj.nullMember2));
            Assert.That(obj2.nonNullMember3, Is.EqualTo(obj.nonNullMember3));
        }
Пример #2
0
        public void should_not_return_null_members_in_serialize_mode()
        {
            var @object = new NullMembers {
                Property = "hai"
            };
            var members = CreateAccessModifierNode(value: new SimpleValue(@object, typeof(NullMembers).ToCachedType()),
                                                   mode: Mode.Serialize).ToList();

            members.ShouldTotal(1);
            members.ShouldNotContainNode("NullProperty");
            members.ShouldContainNode("Property");
        }
Пример #3
0
            public static short Serialize(StreamBuffer outBuffer, object obj)
            {
                NullMembers obj2 = (NullMembers)obj;

                long startPosition = outBuffer.Position;

                SerializeObject(obj2.nullMember1, outBuffer);
                SerializeObject(obj2.nullMember1, outBuffer);

                int offset;

                byte[] buf = outBuffer.GetBufferAndAdvance(sizeof(int), out offset);
                Protocol.Serialize(obj2.nonNullMember3, buf, ref offset);

                return((short)(outBuffer.Position - startPosition));
            }
Пример #4
0
        public void should_not_return_null_members_in_serialize_mode()
        {
            var @object = new NullMembers { Property = "hai" };
            var members = CreateAccessModifierNode(value: new SimpleValue(@object, typeof(NullMembers).ToCachedType()), 
                mode: Mode.Serialize).ToList();

            members.ShouldTotal(1);
            members.ShouldNotContainNode("NullProperty");
            members.ShouldContainNode("Property");
        }