private void WritesQueuedAtCloseLinger_AllSent_Finish(TestRfcommPort port, Stream strm, IAsyncResult ar1, IAsyncResult ar2) { Assert.IsTrue(ar1.IsCompleted, "WritesQueuedAtClose--IsComplete ar1 After close"); Assert.IsTrue(ar2.IsCompleted, "WritesQueuedAtClose--IsComplete ar2 After close"); port.AssertWrittenContent("WritesQueuedAtClose--written--after close", First(Data30, 20), ExceptFirst(Data30, 20), First(Data30, 20), ExceptFirst(Data30, 20) ); strm.EndWrite(ar1); strm.EndWrite(ar2); }
private void WritesQueuedAtCloseLinger_Init(out TestRfcommPort port, out Stream strm, out IAsyncResult ar1, out IAsyncResult ar2) { BluetoothClient cli; Create_ConnectedBluetoothClient_WritePartialsAcceptHalf(out port, out cli, out strm); cli.LingerState = new LingerOption(true, Test_LingerTimeSeconds); // ar1 = strm.BeginWrite(Data30, 0, Data30.Length, null, null); ar2 = strm.BeginWrite(Data30, 0, Data30.Length, null, null); Assert.IsFalse(ar1.IsCompleted, "WritesQueuedAtClose--IsComplete ar1"); port.AssertWrittenContent("WritesQueuedAtClose--written--before", First(Data30, 20)); Assert.IsFalse(ar2.IsCompleted, "WritesQueuedAtClose--IsComplete ar2"); }
private void WritesQueuedAtCloseLinger_OneMoreSent_Finish(TestRfcommPort port, Stream strm, IAsyncResult ar1, IAsyncResult ar2) { Assert.IsTrue(ar1.IsCompleted, "WritesQueuedAtClose--IsComplete ar1 After close"); Assert.IsTrue(ar2.IsCompleted, "WritesQueuedAtClose--IsComplete ar2 After close"); port.AssertWrittenContent("WritesQueuedAtClose--written--after close", First(Data30, 20), ExceptFirst(Data30, 20), First(Data30, 20) ); strm.EndWrite(ar1); try { strm.EndWrite(ar2); Assert.Fail("should have thrown"); } catch (IOException ioex) { Assert.IsInstanceOfType(typeof(SocketException), ioex.InnerException); SocketException ex = (SocketException)ioex.InnerException; Assert.AreEqual(SocketError_NotConnected, ex.ErrorCode); } }