예제 #1
0
        public void testSendOrder()
        {
            var nmsClient = new NmsClientApp("TestClient");

            nmsClient.Configure(BROKER_URL, FER_RESPONSE, FER_COMMAND);
            nmsClient.Start();

            WaitFor(Connected, nmsClient, 1000);
            Assert.IsTrue(nmsClient.Connected(), "Failed to connect");

            var order     = CreateLimitOrder();
            var messageID = nmsClient.SendOrder(order);

            Assert.IsNotNull(messageID, "Failed to send order");
            Console.WriteLine("Sent message:" + messageID);

            // simulate the server processing
            ProcessTestOrder();

            WaitFor(Response, nmsClient, 3000);
            Assert.GreaterOrEqual(nmsClient.OrderCacheCount, 1, "Failed to receive response");
            var response = nmsClient.GetResponseFor(messageID);

            Assert.IsNotNull(response, "Did not receive response for order " + messageID);
            var sentOrder = nmsClient.GetOrderByClientOrderID(order.ClientOrderID);

            Assert.IsNotNull(sentOrder, "Failed to lookup order by clientOrderID");
            Assert.AreNotSame("NEW", sentOrder.Status, "Status not updated to non NEW");

            nmsClient.Stop();
            Assert.IsFalse(nmsClient.Connected(), "Failed to disconnect");
        }
예제 #2
0
        public void testSendOrderIntegration()
        {
            var nmsClient = new NmsClientApp("TestClient");

            nmsClient.Configure(BROKER_URL, FER_RESPONSE, FER_COMMAND);
            nmsClient.Start();

            WaitFor(Connected, nmsClient, 1000);
            Assert.IsTrue(nmsClient.Connected(), "Failed to connect");

            var order = CreateLimitOrder();

            Console.WriteLine("Created order " + order.ClientOrderID);
            var messageID = nmsClient.SendOrder(order);

            Assert.IsNotNull(messageID, "Failed to send order");
            Console.WriteLine("Sent message:" + messageID);

            WaitFor(Response, nmsClient, 3000);
            Assert.GreaterOrEqual(nmsClient.OrderCacheCount, 1, "Failed to receive response");
            var response = nmsClient.GetResponseFor(messageID);

            Thread.Sleep(1000);
            Assert.IsNotNull(response, "Did not receive response for order " + messageID);

            Assert.IsFalse(response.ContainsKey("ERROR_1"), "Error with order:" + GetValueForKey("ERROR_1", response));
            nmsClient.Stop();
            Assert.IsFalse(nmsClient.Connected(), "Failed to disconnect");
        }
예제 #3
0
        public void testStartStop()
        {
            var nmsClient = new NmsClientApp("TestClient");

            nmsClient.Configure(BROKER_URL, FER_RESPONSE, FER_COMMAND);
            nmsClient.Start();

            WaitFor(Connected, nmsClient, 3000);
            Assert.IsTrue(nmsClient.Connected(), "Failed to connect");

            nmsClient.Stop();
            Assert.IsFalse(nmsClient.Connected(), "Failed to disconnect");
        }
예제 #4
0
        public NmsClientApp getClientFor(string brokerUrl)
        {
            lock (instance) {
                if (nmsClients.ContainsKey(brokerUrl))
                {
                    return(nmsClients[brokerUrl]);
                }
                var newClient = new NmsClientApp(brokerUrl);
                // The queues should not change...
                newClient.Configure(brokerUrl, "FER.Response", "FER.Command");
                nmsClients[brokerUrl] = newClient;

                newClient.Start();

                return(newClient);
            }
        }
예제 #5
0
        public void testSessionReconnect()
        {
            var nmsClient = new NmsClientApp("TestClient");

            nmsClient.Configure(BROKER_URL, FER_RESPONSE, FER_COMMAND);
            nmsClient.Start();

            WaitFor(Connected, nmsClient, 1000);
            Assert.IsTrue(nmsClient.Connected(), "Failed to connect");

            Console.WriteLine("Kill the broker NOW!");
            // sleep for a minute so we have time to kill the broker
            Thread.Sleep(60000);
            Console.WriteLine("Going to reconnect, the broker better be up!");

            WaitFor(Connected, nmsClient, 1000);
            Assert.IsTrue(nmsClient.Connected(), "Failed to connect");
        }