Пример #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());
        }