public async void ScoketRead10ByteTest() { SocketReaderTestPeer peer = new SocketReaderTestPeer(); SocketBodyReader reader = new Regulus.Remote.SocketBodyReader(peer); var readBytes = new System.Collections.Generic.List <byte>(); reader.DoneEvent += (data) => { readBytes.AddRange(data); }; reader.Read(10); Regulus.Utility.IStatus status = reader; status.Enter(); while (readBytes.Count < 10) { status.Update(); } status.Leave(); Xunit.Assert.Equal(1, readBytes[1]); Xunit.Assert.Equal(5, readBytes[5]); Xunit.Assert.Equal(9, readBytes[9]); }
public void ScoketRead10ByteTest() { SocketReaderTestPeer peer = new SocketReaderTestPeer(); SocketBodyReader reader = new Regulus.Remote.SocketBodyReader(peer); byte[] readBytes = new byte[10]; bool readed = false; reader.DoneEvent += (data) => { readed = true; readBytes = data; }; reader.Read(10); while (!readed) { } NUnit.Framework.Assert.AreEqual(1, readBytes[1]); NUnit.Framework.Assert.AreEqual(5, readBytes[5]); NUnit.Framework.Assert.AreEqual(9, readBytes[9]); }