public void UnresolvedSubtypeMemberDeserializationYieldsNull() { var serializer = new BinarySerialization.BinarySerializer(); var ingredients = serializer.Deserialize <Ingredients>(new byte[] { 0x4 }); Assert.AreEqual(null, ingredients.MainIngredient); }
public void NonSeekableStreamWithOffsetAttributeShouldThrowInvalidOperationException() { var stream = new NonSeekableStream(); var serializer = new BinarySerialization.BinarySerializer(); serializer.Serialize(stream, Cerealize()); }
public void NonSeekableStreamDeserializationTest() { var stream = new NonSeekableStream(); var serializer = new BinarySerialization.BinarySerializer(); serializer.Serialize(stream, new Iron()); }
public void NullGraphSerializationShouldSerializeNothing() { var serializer = new BinarySerialization.BinarySerializer(); var stream = new MemoryStream(); serializer.Serialize(stream, null); Assert.AreEqual(0, stream.Length); }
public void UnknownTypeSerializationTest() { var unknownTypeClass = new UnknownTypeClass {Field = "hello"}; var serializer = new BinarySerialization.BinarySerializer(); var stream = new MemoryStream(); serializer.Serialize(stream, unknownTypeClass); }
public void SubtypesOnUnknownTypeFieldShouldThrowBindingException() { var unknownTypeClass = new InvalidUnknownTypeClass { Field = "hello" }; var serializer = new BinarySerialization.BinarySerializer(); var stream = new MemoryStream(); serializer.Serialize(stream, unknownTypeClass); }
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); }
public void UnknownTypeSerializationTest() { var unknownTypeClass = new UnknownTypeClass { Field = "hello" }; var serializer = new BinarySerialization.BinarySerializer(); var stream = new MemoryStream(); serializer.Serialize(stream, unknownTypeClass); }
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]); }
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]); }
public void NullStreamSerializationShouldThrowNullArgumentException() { var serializer = new BinarySerialization.BinarySerializer(); serializer.Serialize(null, new object()); }