private void InitializeApi() { if (_api == null || _api.ConnectionDropped) { _api = new TradingScreenApi { UserId = ApiUserId, Password = ApiPassword, Site = ApiSite, PricingServer = ApiPricingServer }; } }
public void TestLogon() { var api = new TradingScreenApi { UserId = "malbec2_uat", Password = "******", Site = "UAT Prod B", PricingServer = "tcp://uatprod.trandingscreen.net:9901" }; Assert.IsFalse(api.LoggedIn); Assert.IsFalse(api.LoginStarted); Assert.IsTrue(api.Login()); Assert.IsFalse(api.LoginStarted); Assert.IsTrue(api.LoggedIn); Assert.IsNotNull(api.LastLoginMessage); Assert.AreEqual("OK", api.StartListeningForOrders(TestOrderEventHandler)); // wait for a second in case we have orders to receive Thread.Sleep(1000); Assert.IsTrue(api.Logout()); }
public void TestLogonThreaded() { var api = new TradingScreenApi { UserId = "malbec2_uat", Password = "******", Site = "UAT Prod B", PricingServer = "tcp://uatprod.trandingscreen.net:9901" }; Assert.IsFalse(api.LoggedIn); Assert.IsFalse(api.LoginStarted); Assert.IsTrue(api.StartLogonProcess()); Assert.IsTrue(api.LoginStarted); WaitFor(LoggedIn, api, 60000); Assert.IsTrue(api.LoggedIn); Assert.IsNotNull(api.LastLoginMessage); // The API will state we are logged in before we receive the LoginOK status message. WaitFor(LoginFinished, api, 30000); Assert.IsFalse(api.LoginStarted); Assert.AreEqual("OK", api.StartListeningForOrders(TestOrderEventHandler)); // wait for a second in case we have orders to receive Thread.Sleep(1000); Assert.IsTrue(api.Logout()); }