Esempio n. 1
0
        public void TestSendOrder()
        {
            var nmsClient = new NmsClientApp("TestClient");

            nmsClient.Configure(BrokerUrl, FerCommandQueue);
            nmsClient.Start();

            WaitFor(Connected, nmsClient, 10000);
            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.GetOrderByKey(order.CacheKey);

            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");
        }
Esempio n. 2
0
        public void TestSendOrderIntegration()
        {
            var nmsClient = new NmsClientApp("TestClient");

            nmsClient.Configure(BrokerUrl, FerCommandQueue);
            nmsClient.Start();

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

            var order = CreateLimitOrder();

            // Since this is an integration test, change platform to 'TEST'
            order.platform = "TEST";
            order.strategy = "TEST-EQUITY-STRATEGY";

            Console.WriteLine("Created order " + order.CacheKey);
            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");
            Thread.Sleep(1000);
            var response = nmsClient.GetResponseFor(messageId);

            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");
        }
Esempio n. 3
0
 /// <summary>
 /// Stop the nms client as we are shutting down.
 ///
 /// If we are still publishing, the publishier will restart, so we are O.K.
 /// </summary>
 void IRtdServer.ServerTerminate()
 {
     try {
         nmsClient.Stop();
     } catch (Exception e) {
         //log.Error(e);
         Console.Write(e);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Stop the nms client as we are shutting down.
 ///
 /// If we are still publishing, the publishier will restart, so we are O.K.
 /// </summary>
 public void ServerTerminate()
 {
     try {
         _nmsClient.Stop();
     } catch (Exception e) {
         //_log.Error(e);
         Console.Write(e);
     }
 }
Esempio n. 5
0
        public void TestStartStop()
        {
            var nmsClient = new NmsClientApp("TestClient");

            nmsClient.Configure(BrokerUrl, FerCommandQueue);
            nmsClient.Start();

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

            nmsClient.Stop();
            Assert.IsFalse(nmsClient.Connected(), "Failed to disconnect");
        }