public void SerializeTestWithStreamAsync() { int val = int.MaxValue; var stream = new FakePipeStream(); BssomSerializer.SerializeAsync(stream, val).Wait(); stream.CurrentCursor().Is(5); BssomSerializer.Deserialize <int>(stream.ToArray(), 0, out int readSize).Is(int.MaxValue); readSize.Is(5); }
public void MemoryStreamSerializeAsyncTest(Type type) { var obj = RandomHelper.RandomValueWithOutStringEmpty(type); byte[] buf = BssomSerializer.Serialize(obj); MemoryStream stream = new MemoryStream(); BssomSerializer.SerializeAsync(stream, obj).Wait(); stream.Position.Is(buf.Length); buf.Is(stream.ToArray()); }
public void PipeStreamSerializeAsyncTest(Type type) { var obj = RandomHelper.RandomValueWithOutStringEmpty(type); byte[] buf = BssomSerializer.Serialize(obj); FakePipeStream stream = new FakePipeStream(); BssomSerializer.SerializeAsync(stream, obj).Wait(); stream.CurrentCursor().Is(buf.Length); buf.Is(stream.ToArray()); }