diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs index 620e33f8c1..f00ddf3f62 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs @@ -57,25 +57,72 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests } } + /// + /// Add a client for testing + /// + /// + /// Agent circuit manager used in setting up the stack + protected void SetupStack( out TestLLUDPServer testLLUDPServer, out AgentCircuitManager acm) + { + ClientStackUserSettings userSettings = new ClientStackUserSettings(); + testLLUDPServer = new TestLLUDPServer(); + acm = new AgentCircuitManager(); + + uint port = 666; + testLLUDPServer.Initialise(null, ref port, 0, false, userSettings, null, acm); + new LLPacketServer(testLLUDPServer, userSettings); + testLLUDPServer.LocalScene = new MockScene(); + } + + /// + /// Set up a client for tests which aren't concerned with this process itself + /// + /// + /// + /// + protected void AddClient(uint circuitCode, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) + { + UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); + UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); + + AgentCircuitData acd = new AgentCircuitData(); + acd.AgentID = myAgentUuid; + acd.SessionID = mySessionUuid; + + UseCircuitCodePacket uccp = new UseCircuitCodePacket(); + + UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock + = new OpenMetaverse.Packets.UseCircuitCodePacket.CircuitCodeBlock(); + uccpCcBlock.Code = circuitCode; + uccpCcBlock.ID = myAgentUuid; + uccpCcBlock.SessionID = mySessionUuid; + uccp.CircuitCode = uccpCcBlock; + + EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); + + acm.AddNewCircuit(circuitCode, acd); + + testLLUDPServer.LoadReceive(uccp, testEp); + testLLUDPServer.ReceiveData(null); + } + [Test] + /// + /// Test adding a client to the stack + /// public void TestAddClient() { uint myCircuitCode = 123456; UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); - TestLLUDPServer testLLUDPServer = new TestLLUDPServer(); - ClientStackUserSettings userSettings = new ClientStackUserSettings(); + TestLLUDPServer testLLUDPServer; + AgentCircuitManager acm; + SetupStack(out testLLUDPServer, out acm); - AgentCircuitManager acm = new AgentCircuitManager(); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = myAgentUuid; - acd.SessionID = mySessionUuid; - - uint port = 666; - testLLUDPServer.Initialise(null, ref port, 0, false, userSettings, null, acm); - new LLPacketServer(testLLUDPServer, userSettings); - testLLUDPServer.LocalScene = new MockScene(); + acd.SessionID = mySessionUuid; UseCircuitCodePacket uccp = new UseCircuitCodePacket(); @@ -103,5 +150,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); Assert.IsFalse(testLLUDPServer.HasCircuit(101)); } + + [Test] + /// + /// Test removing a client from the stack + /// + public void TestRemoveClient() + { + TestLLUDPServer testLLUDPServer; + AgentCircuitManager acm; + SetupStack(out testLLUDPServer, out acm); + + AddClient(123457, testLLUDPServer, acm); + } } }