public void CreateWorld() { using (var client = new Client("Test")) { client.ResetEvent(); client.SendOperation(Operations.CreateWorld("CreateWorld", new BoundingBox(new Vector(0f, 0f, 0f), new Vector(10f, 10f, 0f)), new Vector(1f, 1f, 0f))); client.BeginReceiveResponse(); OperationResponse data; Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received"); // blocking Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok); // "Test" defined in setup client.ResetEvent(); client.SendOperation(Operations.CreateWorld("TestWorld", new BoundingBox(new Vector(0f, 0f, 0f), new Vector(10f, 10f, 0f)), new Vector(1f, 1f, 0f))); client.BeginReceiveResponse(); Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received"); // blocking Assert.AreEqual(data.ReturnCode, (byte)ReturnCode.WorldAlreadyExists); } }
public void DetachCamera() { using (var client = new Client("Test")) { EnterWorld(client, "TestWorld", new Vector(1f, 1f), new Vector(1f, 1f), new Vector(2f, 2f), null); client.ResetEvent(); client.SendOperation(Operations.DetachCamera()); client.BeginReceiveResponse(); OperationResponse data; Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received"); // blocking Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok); } }
private static void EnterWorldBegin(Client client, World world, Vector position) { var viewDistanceEnter = new Vector(1f, 1f); var viewDistanceExit = new Vector(2f, 2f); client.Position = position; ThreadPoolEnqueue( client, () => { client.SendOperation(Operations.EnterWorld(world.Name, client.Username, null, position, viewDistanceEnter, viewDistanceExit)); client.BeginReceiveResponse(); }); }
public void AttachCamera() { using (var client = new Client("Test")) { SpawnItem(client); client.SendOperation(Operations.AttachCamera("MyItem", byte.MaxValue)); client.BeginReceiveResponse(); OperationResponse data; Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Event not received"); Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok); Func<OperationResponse, bool> checkAction = e => (string)e.Parameters[(byte)ParameterCode.ItemId] == "MyItem" && (byte)e.Parameters[(byte)ParameterCode.ItemType] == byte.MaxValue; Assert.IsTrue(checkAction(data), "check action failed"); } }
public void AttachCamera() { using (var client = new Client("Test")) { SpawnItem(client); client.SendOperation(Operations.AttachCamera("MyItem", byte.MaxValue)); client.BeginReceiveResponse(); OperationResponse data; Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Event not received"); Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok); Func <OperationResponse, bool> checkAction = e => (string)e.Parameters[(byte)ParameterCode.ItemId] == "MyItem" && (byte)e.Parameters[(byte)ParameterCode.ItemType] == byte.MaxValue; Assert.IsTrue(checkAction(data), "check action failed"); } }
/// <summary> /// The enter world. /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="world"> /// The world. /// </param> /// <param name="position"> /// The position. /// </param> private static void EnterWorldBegin(Client client, MmoWorld world, float[] position) { var viewDistanceEnter = new[] { 1f, 1f }; var viewDistanceExit = new[] { 2f, 2f }; client.Position = position; ThreadPoolEnqueue( client, () => { client.SendOperation(Operations.EnterWorld(world.Name, client.Username, null, position, viewDistanceEnter, viewDistanceExit)); client.BeginReceiveResponse(); }); }
/// <summary> /// The receive operation response. /// </summary> /// <param name="client"> /// The client. /// </param> /// <returns> /// the operation response /// </returns> private static OperationResponse ReceiveOperationResponse(Client client) { client.BeginReceiveResponse(); OperationResponse data; Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received"); return data; }
/// <summary> /// The receive operation response. /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="expectedReturn"> /// The expected Return. /// </param> private static void ReceiveOperationResponse(Client client, ReturnCode expectedReturn) { client.BeginReceiveResponse(); OperationResponse data; Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received"); var errorCode = (ReturnCode)data.ReturnCode; Assert.AreEqual(errorCode, expectedReturn); }
/// <summary> /// The not receive operation response. /// </summary> /// <param name="client"> /// The client. /// </param> private static void NotReceiveOperationResponse(Client client) { client.BeginReceiveResponse(); OperationResponse data; Assert.IsFalse(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received"); }
public void DetachCamera() { using (var client = new Client("Test")) { EnterWorld(client, "TestWorld", new[] { 1f, 1f }, new[] { 1f, 1f }, new[] { 2f, 2f }, null); client.SendOperation(Operations.DetachCamera()); client.BeginReceiveResponse(); OperationResponse data; Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received"); Assert.AreEqual(data.ReturnCode, (int)ReturnCode.Ok); } }