コード例 #1
0
        public void UnresolvedSubtypeMemberDeserializationYieldsNull()
        {
            var serializer  = new BinarySerialization.BinarySerializer();
            var ingredients = serializer.Deserialize <Ingredients>(new byte[] { 0x4 });

            Assert.AreEqual(null, ingredients.MainIngredient);
        }
コード例 #2
0
        public void NonSeekableStreamWithOffsetAttributeShouldThrowInvalidOperationException()
        {
            var stream     = new NonSeekableStream();
            var serializer = new BinarySerialization.BinarySerializer();

            serializer.Serialize(stream, Cerealize());
        }
コード例 #3
0
        public void NonSeekableStreamDeserializationTest()
        {
            var stream     = new NonSeekableStream();
            var serializer = new BinarySerialization.BinarySerializer();

            serializer.Serialize(stream, new Iron());
        }
コード例 #4
0
        public void NullGraphSerializationShouldSerializeNothing()
        {
            var serializer = new BinarySerialization.BinarySerializer();
            var stream     = new MemoryStream();

            serializer.Serialize(stream, null);
            Assert.AreEqual(0, stream.Length);
        }
コード例 #5
0
        public void UnknownTypeSerializationTest()
        {
            var unknownTypeClass = new UnknownTypeClass {Field = "hello"};

            var serializer = new BinarySerialization.BinarySerializer();

            var stream = new MemoryStream();
            serializer.Serialize(stream, unknownTypeClass);
        }
コード例 #6
0
        public void SubtypesOnUnknownTypeFieldShouldThrowBindingException()
        {
            var unknownTypeClass = new InvalidUnknownTypeClass { Field = "hello" };

            var serializer = new BinarySerialization.BinarySerializer();

            var stream = new MemoryStream();
            serializer.Serialize(stream, unknownTypeClass);
        }
コード例 #7
0
        public void ImplicitTermination()
        {
            var data = new byte[] { 0x0, 0x1, 0x2, 0x3 };

            var serializer = new BinarySerialization.BinarySerializer();
            var byteList   = serializer.Deserialize <ImplictTermination>(data);

            Assert.AreEqual(4, byteList.Data.Count);
        }
コード例 #8
0
        public void SubtypesOnUnknownTypeFieldShouldThrowBindingException()
        {
            var unknownTypeClass = new InvalidUnknownTypeClass {
                Field = "hello"
            };

            var serializer = new BinarySerialization.BinarySerializer();

            var stream = new MemoryStream();

            serializer.Serialize(stream, unknownTypeClass);
        }
コード例 #9
0
        public void UnknownTypeSerializationTest()
        {
            var unknownTypeClass = new UnknownTypeClass {
                Field = "hello"
            };

            var serializer = new BinarySerialization.BinarySerializer();

            var stream = new MemoryStream();

            serializer.Serialize(stream, unknownTypeClass);
        }
コード例 #10
0
        public void BindingAcrossUnknownBoundaryTest()
        {
            var childClass = new BindingAcrossUnknownBoundaryChildClass {Subfield = "hello"};
            var unknownTypeClass = new BindingAcrossUnknownBoundaryClass
            {
                Field = childClass
            };

            var serializer = new BinarySerialization.BinarySerializer();

            var stream = new MemoryStream();
            serializer.Serialize(stream, unknownTypeClass);

            var data = stream.ToArray();

            Assert.AreEqual((byte)childClass.Subfield.Length, data[0]);
        }
コード例 #11
0
        public void BindingAcrossUnknownBoundaryTest()
        {
            var childClass = new BindingAcrossUnknownBoundaryChildClass {
                Subfield = "hello"
            };
            var unknownTypeClass = new BindingAcrossUnknownBoundaryClass
            {
                Field = childClass
            };

            var serializer = new BinarySerialization.BinarySerializer();

            var stream = new MemoryStream();

            serializer.Serialize(stream, unknownTypeClass);

            var data = stream.ToArray();

            Assert.AreEqual((byte)childClass.Subfield.Length, data[0]);
        }
コード例 #12
0
        public void NullStreamSerializationShouldThrowNullArgumentException()
        {
            var serializer = new BinarySerialization.BinarySerializer();

            serializer.Serialize(null, new object());
        }