public void AsyncWrite() { NonAbstractStream s = new NonAbstractStream(); message = "AsyncWrite"; reset.Reset(); IAsyncResult r = s.BeginWrite(null, 0, 0, new AsyncCallback(WriteCallback), s); Assert.IsNotNull(r, "IAsyncResult"); if (!reset.WaitOne(timeout, true)) { Assert.Ignore("Timeout"); } Assert.IsNull(message, message); }
private void WriteCallback(IAsyncResult ar) { NonAbstractStream s = (NonAbstractStream)ar.AsyncState; s.EndWrite(ar); try { // can we do something bad here ? Assert.IsNotNull(Environment.GetEnvironmentVariable("USERNAME")); message = "Expected a SecurityException"; } catch (SecurityException) { message = null; reset.Set(); } catch (Exception e) { message = e.ToString(); } }
public void AsyncWrite () { NonAbstractStream s = new NonAbstractStream (); message = "AsyncWrite"; reset.Reset (); IAsyncResult r = s.BeginWrite (null, 0, 0, new AsyncCallback (WriteCallback), s); Assert.IsNotNull (r, "IAsyncResult"); if (!reset.WaitOne (timeout, true)) Assert.Ignore ("Timeout"); Assert.IsNull (message, message); }