public void ReadAfter() { var stuff = ClientTestingBluetopia.Open(); Assert.IsNotNull(stuff.DutClient, "DutClient"); Assert.IsNotNull(stuff.DutConn, "DutConn"); // byte[] srcBuf = SendReceiveTen(stuff); // byte[] buf = new byte[100]; int readLen = stuff.DutConn.Read(buf, 0, buf.Length); Assert.AreEqual(10, readLen, "readLen"); Assert2.AreEqual_Buffers(srcBuf, buf, 0, readLen, "buf content"); // stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); ClientTestingBluetopia.Close(stuff); }
public void ReadBeginBefore() { var stuff = ClientTestingBluetopia.Open(); Assert.IsNotNull(stuff.DutClient, "DutClient"); Assert.IsNotNull(stuff.DutConn, "DutConn"); // byte[] buf = new byte[100]; var ar = stuff.DutConn.BeginRead(buf, 0, buf.Length, null, null); Assert.IsFalse(ar.IsCompleted); // byte[] srcBuf = SendReceiveTen(stuff); // Assert.IsTrue(ar.IsCompleted); int readLen = stuff.DutConn.EndRead(ar); Assert.AreEqual(10, readLen, "readLen"); Assert2.AreEqual_Buffers(srcBuf, buf, 0, readLen, "buf content"); // stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); ClientTestingBluetopia.Close(stuff); }
public void ReadBeginBeforeTwoParts() { var stuff = ClientTestingBluetopia.Open(); Assert.IsNotNull(stuff.DutClient, "DutClient"); Assert.IsNotNull(stuff.DutConn, "DutConn"); // byte[] buf = new byte[100]; byte[] buf2 = new byte[100]; var ar = stuff.DutConn.BeginRead(buf, 0, 5, null, null); var ar2 = stuff.DutConn.BeginRead(buf2, 0, buf2.Length, null, null); Assert.IsFalse(ar.IsCompleted); Assert.IsFalse(ar2.IsCompleted); // byte[] srcBuf = SendReceiveTen(stuff); // byte[] srcBufPart1 = new byte[5]; Array.Copy(srcBuf, 0, srcBufPart1, 0, srcBufPart1.Length); byte[] srcBufPart2 = new byte[5]; Array.Copy(srcBuf, srcBufPart1.Length, srcBufPart2, 0, srcBufPart2.Length); // Assert.IsTrue(ar.IsCompleted); Assert.IsTrue(ar2.IsCompleted); int readLen = stuff.DutConn.EndRead(ar); Assert.AreEqual(5, readLen, "readLen"); Assert2.AreEqual_Buffers(srcBufPart1, buf, 0, readLen, "buf content Part1"); int readLen2 = stuff.DutConn.EndRead(ar); Assert.AreEqual(5, readLen, "readLen"); Assert2.AreEqual_Buffers(srcBufPart2, buf2, 0, readLen2, "buf content Part2"); // stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); ClientTestingBluetopia.Close(stuff); }