public void BeginRead_should_be_callable_indirectly()
{
using (new IndirectionsContext())
{
// Arrange
PStream.BeginReadByteArrayInt32Int32AsyncCallbackObject().Body = (@this, _buffer, offset, count, callback, state) =>
IndirectionsContext.ExecuteOriginal(() => @this.BeginRead(_buffer, offset, 42, callback, state));
var buffer = new byte[256];
for (int i = 0; i < buffer.Length; i++)
buffer[i] = (byte)i;
using (var ms = new MemoryStream(buffer))
{
// Act
var _buffer = new byte[1024];
var ar = ms.BeginRead(_buffer, 0, _buffer.Length, null, null);
var actual = ms.EndRead(ar);
// Assert
Assert.AreEqual(42, actual);
}
}
}