Files
libremetaverse/libsecondlife-cs/libsecondlife.Tests/NetworkTests.cs
John Hurliman d695369b51 * Set CAPS KeepAlive to false to resolve issue 67
* Big refactoring of GridManager, no more five second sleep. Added MapLayer CAPS stub. GridRegion is now a struct and GetGridRegion() returns a bool
* LLSD integer type now maps to C# type int instead of long. Misc cleanups in LLSD, more is and as usage
* Added RegionFlags and SimAccess enums
* Another try/catch in SLProxy for CAPS connection problems
* Simulator.Equals now compares based on IPEndPoint, == and != overloads added
* Added a stub for making CAPS calls (awaiting the NetworkManager message pumps)
* More CAPS error handling for 404, timed out connections, and misc problems
* FindSim and Goto commands no longer sleep or try to download info on every sim in the grid
* More logging messages output the simulator name that they originated from
* Helpers.FieldToHexString now properly prints the given field name
* Another disconnect sanity check in NetworkManager
* Log() and DebugLog() now use String.Format. Always use String.Format when there are lots of parameters!
* Settings.cs documentation, CROSS_BORDERS renamed to MULTIPLE_SIMS
* Removed pointless libsecondlife.nunit file

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1060 52acb1d6-8a22-11de-b505-999d5b087335
2007-03-21 15:24:51 +00:00

121 lines
4.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Net;
using libsecondlife;
using libsecondlife.Packets;
using libsecondlife.Utilities;
using NUnit.Framework;
namespace libsecondlife.Tests
{
[TestFixture]
public class NetworkTests : Assert
{
SecondLife Client;
ulong CurrentRegionHandle = 0;
ulong AhernRegionHandle = 1096213093149184;
ulong MorrisRegionHandle = 1096213093149183;
bool DetectedObject = false;
LLUUID LookupKey1 = new LLUUID("25472683cb324516904a6cd0ecabf128");
//string LookupName1 = "Bot Ringo";
public NetworkTests()
{
Client = new SecondLife();
// Register callbacks
Client.Network.RegisterCallback(PacketType.ObjectUpdate, new NetworkManager.PacketCallback(ObjectUpdateHandler));
//Client.Self.OnTeleport += new MainAvatar.TeleportCallback(OnTeleportHandler);
// Connect to the grid
string startLoc = NetworkManager.StartLocation("Ahern", 128, 128, 32);
Client.Network.Login("Testing", "Anvil", "testinganvil", "Unit Test Framework", startLoc,
"contact@libsecondlife.org", false);
}
~NetworkTests()
{
Client.Network.Logout();
}
[SetUp]
public void Init()
{
Assert.IsTrue(Client.Network.Connected, "Client is not connected to the grid: " + Client.Network.LoginError);
int start = Environment.TickCount;
Assert.AreEqual("ahern", Client.Network.CurrentSim.Name.ToLower(), "Logged in to sim " +
Client.Network.CurrentSim.Name + " instead of Ahern");
}
[Test]
public void DetectObjects()
{
int start = Environment.TickCount;
while (!DetectedObject)
{
if (Environment.TickCount - start > 10000)
{
Assert.Fail("Timeout waiting for an ObjectUpdate packet");
}
}
}
[Test]
public void U64Receive()
{
int start = Environment.TickCount;
while (CurrentRegionHandle == 0)
{
if (Environment.TickCount - start > 10000)
{
Assert.Fail("Timeout waiting for an ObjectUpdate packet");
}
}
Assert.IsTrue(CurrentRegionHandle == AhernRegionHandle, "Current region is " +
CurrentRegionHandle + " when we were expecting " + AhernRegionHandle + ", possible endian issue");
}
[Test]
public void Teleport()
{
Assert.IsTrue(Client.Self.Teleport(MorrisRegionHandle, new LLVector3(128, 128, 32)),
"Teleport to Morris failed");
// Assert that we really did make it to our scheduled destination
Assert.AreEqual("morris", Client.Network.CurrentSim.Name.ToLower(),
"Expected to teleport to Morris, ended up in " + Client.Network.CurrentSim.Name +
". Possibly region full or offline?");
///////////////////////////////////////////////////////////////////
// TODO: Add a local region teleport
///////////////////////////////////////////////////////////////////
Assert.IsTrue(Client.Self.Teleport(AhernRegionHandle, new LLVector3(128, 128, 32)),
"Teleport to Ahern failed");
// Assert that we really did make it to our scheduled destination
Assert.AreEqual("ahern", Client.Network.CurrentSim.Name.ToLower(),
"Expected to teleport to Ahern, ended up in " + Client.Network.CurrentSim.Name +
". Possibly region full or offline?");
}
private void ObjectUpdateHandler(Packet packet, Simulator sim)
{
ObjectUpdatePacket update = (ObjectUpdatePacket)packet;
DetectedObject = true;
CurrentRegionHandle = update.RegionData.RegionHandle;
}
[TearDown]
public void Shutdown()
{
}
}
}