Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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();
            });
        }
Exemplo n.º 4
0
        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");
            }
        }
Exemplo n.º 5
0
        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");
            }
        }
Exemplo n.º 6
0
        /// <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();
                });
        }
Exemplo n.º 7
0
        /// <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;
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        /// <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");
        }
Exemplo n.º 10
0
        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);
            }
        }