public void StreamReadsAndWrites() { var input = new byte[] { 1, 2, 3, 4, 5 }; using (var stream = new ValueStream()) { stream.Write(input, 0, input.Length); stream.Seek(0); var result = new byte[5]; var read = stream.Read(result, 0, result.Length); Assert.Equal(result.Length, read); Assert.Equal(input, result); } }
public void ReadByteWriteByteWorks() { using (var stream = new ValueStream()) { stream.WriteByte(1); stream.WriteByte(2); stream.WriteByte(3); stream.WriteByte(4); stream.WriteByte(5); stream.Seek(0); Assert.Equal(1, stream.ReadByte()); Assert.Equal(2, stream.ReadByte()); Assert.Equal(3, stream.ReadByte()); Assert.Equal(4, stream.ReadByte()); Assert.Equal(5, stream.ReadByte()); } }
public void DoubleResizing() { var input = new byte[] { 1, 2, 3, 4, 5 }; using (var stream = new ValueStream()) { stream.Write(input, 0, input.Length); stream.Write(input, 0, input.Length); Assert.Equal(10, stream.Position); stream.Seek(0); var result = new byte[5]; stream.Read(result, 0, result.Length); Assert.Equal(input, result); stream.Read(result, 0, result.Length); Assert.Equal(input, result); } }
static void Main(string[] args) { Test[] test = new Test[] { new Test3 { Prop = false, Prop2 = 123 }, new Test2 { Prop = false, Prop2 = 12 }, new Test3() }; var config = new SerializerConfig(); config.Match <Test>(); config.Match <Test3>(); var serializer = config.Create(); using (var stream = new ValueStream()) { serializer.Serialize(stream, test); stream.Seek(0); var instance = serializer.Deserialize <Test[]>(stream); } }