* refactor: factor out test packet send method in client stack unit tests

This commit is contained in:
Justin Clarke Casey
2008-11-06 18:27:56 +00:00
parent 46492f3c11
commit 8477aab8e0
2 changed files with 66 additions and 10 deletions

View File

@@ -48,7 +48,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
protected override void BeginReceive()
{
// Do nothing
if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException)
{
ChunkSenderTuple tuple = m_chunksToLoad.Dequeue();
reusedEpSender = tuple.Sender;
throw new SocketException();
}
}
protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
@@ -71,6 +76,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
// Don't do anything just yet
}
/// <summary>
/// Signal that this chunk should throw an exception on Socket.BeginReceive()
/// </summary>
/// <param name="epSender"></param>
public void LoadReceiveWithBeginException(EndPoint epSender)
{
ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
tuple.BeginReceiveException = true;
m_chunksToLoad.Enqueue(tuple);
}
/// <summary>
/// Load some data to be received by the LLUDPServer on the next receive call
/// </summary>
@@ -118,14 +134,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
/// Record the data and sender tuple
/// </summary>
public class ChunkSenderTuple
{
{
public byte[] Data;
public EndPoint Sender;
public bool BeginReceiveException;
public ChunkSenderTuple(byte[] data, EndPoint sender)
{
Data = data;
Sender = sender;
}
public ChunkSenderTuple(EndPoint sender)
{
Sender = sender;
}
}
}