public void DeserializeTestWithStreamAsync_Type() { int val = int.MaxValue; var buf = BssomSerializer.Serialize(val); var stream = new FakePipeStream(buf); ((int)(BssomSerializer.DeserializeAsync(stream, typeof(int)).Result)).Is(int.MaxValue); stream.CurrentCursor().Is(5); }
public void DeserializeTestWithStreamAsync() { int val = int.MaxValue; var buf = BssomSerializer.Serialize(val); var stream = new FakePipeStream(buf); BssomSerializer.DeserializeAsync <int>(stream).Result.Is(int.MaxValue); stream.CurrentCursor().Is(5); }
public void DeserializeTestWithStream_Type_Context() { int val = int.MaxValue; var context = new BssomDeserializeContext(); var buf = BssomSerializer.Serialize(val); var stream = new FakePipeStream(buf); ((int)BssomSerializer.Deserialize(ref context, stream, typeof(int))).Is(int.MaxValue); stream.CurrentCursor().Is(5); }
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 SerializeTestWithContext_Stream() { int val = int.MaxValue; var context = new BssomSerializeContext(); var stream = new FakePipeStream(); BssomSerializer.Serialize(ref context, val, stream); stream.CurrentCursor().Is(5); BssomSerializer.Deserialize <int>(stream.ToArray(), 0, out int readSize).Is(int.MaxValue); readSize.Is(5); }
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()); }