Beispiel #1
0
        private static void EnterWorldEnd(Client client)
        {
            OperationResponse data;

            Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTimeMultiOp, out data));
            Assert.AreEqual(0, data.ReturnCode);
            Console.WriteLine("EnterWorldEnd " + client.Username + " " + data + " " + Interlocked.Increment(ref counterEnterWorldEnd));
        }
Beispiel #2
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");
        }
        private static OperationResponse ReceiveOperationResponse(Client client)
        {
            client.BeginReceiveResponse();

            OperationResponse data;

            Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data), "Response not received");
            return(data);
        }
        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 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);
            }
        }
        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);
        }
Beispiel #7
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);
            }
        }
        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");
            }
        }
Beispiel #9
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");
            }
        }
Beispiel #10
0
 /// <summary>
 /// The enter world end.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 private static void EnterWorldEnd(Client client)
 {
     OperationResponse data;
     Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTime, out data));
     Assert.AreEqual(0, data.ReturnCode);
 }
        /// <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);
            }
        }