public void ShouldWaitForBuffer() { var receiveCalled = false; var receiveWaiter = new ManualResetEvent(false); var worker = new TestWorkScheduler(); worker.QueueForeverAction = (action, span) => { Task.Factory.StartNew(() => { while (true) { action(); } }); }; var bufferAllocator = new TestBufferAllocator(); var connection = new TestConnection(); var io = new ConnectionIoActor(worker, bufferAllocator); bufferAllocator.AllocateFunc = i => null; connection.ReceiveAction = (buffer, callback) => { receiveCalled = true; receiveWaiter.Set(); }; io.Receive(128, connection, new BandwidthController(), null, null); bufferAllocator.AllocateFunc = i => new Buffer(new byte[128]); receiveWaiter.WaitOne(100); Assert.IsTrue(receiveCalled, "Receive was not called."); }
public void ShouldWaitForBuffer() { var receiveCalled = false; var receiveWaiter = new ManualResetEvent(false); var worker = new TestWorkScheduler(); worker.QueueForeverAction = (action, span) => { Task.Factory.StartNew(() => { while (true) action(); }); }; var bufferAllocator = new TestBufferAllocator(); var connection = new TestConnection(); var io = new ConnectionIoActor(worker, bufferAllocator); bufferAllocator.AllocateFunc= i => null; connection.ReceiveAction = (buffer, callback) => { receiveCalled = true; receiveWaiter.Set(); }; io.Receive(128, connection, new BandwidthController(), null, null ); bufferAllocator.AllocateFunc = i => new Buffer(new byte[128]); receiveWaiter.WaitOne(100); Assert.IsTrue(receiveCalled, "Receive was not called."); }