public void testIsolatedAimMessages() { O.freezeNow("07/01/2009"); MarketTickersTable.TICKERS.C_BLOOMBERG.updateOne(MarketTickersTable.TICKERS.C_MARKET.@is("FV.1C"), "anything"); MarketTickersTable.TICKERS.C_BLOOMBERG.updateOne(MarketTickersTable.TICKERS.C_MARKET.@is("TU.1C"), "TOE"); var fvTopic = LiveWatcher.tickerTopic("QF.NDayBreak", "anything", "Comdty"); var tuTopic = LiveWatcher.tickerTopic("QF.NDayBreak", "TOE", "Comdty"); var brokenTopic = LiveWatcher.tickerTopic("QF.NDayBreak", "BROKE", "Comdty"); var fakeGui = new FakeWatcherGui(); var watcher = new LiveWatcher(fakeGui); watcher.initialize(); watcher.eachRow(row => AreEqual(row["aim"], 0)); watcher.requireContains("QF.NDayBreak", "anything Comdty"); var fv1C = new Symbol("FV.1C"); var tu1C = new Symbol("TU.1C"); Action <Symbol, double> waitForCount = (symbol, expected) => fakeGui.waitMatches(expected, () => watcher.row("QF.NDayBreak", symbol)["aim"]); publishAim(fvTopic, "QF.NDayBreak", "anything", "COMDTY", 3, "2009/07/01 14:00:00"); waitForCount(fv1C, 3); publishAim(fvTopic, "QF.NDayBreak", "anything", "COMDTY", 2, "2009/07/01 14:00:01"); waitForCount(fv1C, 2); publishAim(tuTopic, "QF.NDayBreak", "TOE", "COMDTY", 5, "2009/07/01 14:00:03"); waitForCount(tu1C, 5); publishAim(brokenTopic, "QF.NDayBreak", "BROKE", "COMDTY", 7, "2009/07/01 14:00:03"); fakeGui.waitMatches(7.0, () => watcher.firstRow()["aim"]); AreEqual(watcher.firstRow()["symbol"], "BROKE Comdty"); }
public void testIntegratedMessages() { O.freezeNow("07/01/2009"); MarketTickersTable.TICKERS.C_BLOOMBERG.updateOne(MarketTickersTable.TICKERS.C_MARKET.@is("FV.1C"), "anything"); MarketTickersTable.TICKERS.C_BLOOMBERG.updateOne(MarketTickersTable.TICKERS.C_MARKET.@is("TU.1C"), "TOE"); var nday20 = new Topic("TOMAHAWK.NDayBreak.1.0.daily.BFBD20.FV.1C.optimalPosition"); var nday30 = new Topic("TOMAHAWK.NDayBreak.1.0.daily.BFBD30.FV.1C.optimalPosition"); var fvTopic = LiveWatcher.tickerTopic("QF.NDayBreak", "anything", "Comdty"); var tuTopic = LiveWatcher.tickerTopic("QF.NDayBreak", "TOE", "Comdty"); var brokenTopic = LiveWatcher.tickerTopic("QF.NDayBreak", "BROKE", "Comdty"); var fakeGui = new FakeWatcherGui(); var watcher = new LiveWatcher(fakeGui); watcher.initialize(); var fv1C = new Symbol("FV.1C"); var tu1C = new Symbol("TU.1C"); tu1C.setTypeForTest("Equity"); Action <Symbol, double, double, double> waitForCount = (symbol, aim, tomahawk, diff) => { var last = new [] { 0.0, 0, 0 }; try { fakeGui.wait(() => { var row = watcher.row("QF.NDayBreak", symbol); last[0] = (double)row["aim"]; last[1] = (double)row["tomahawk"]; last[2] = (double)row["diff"]; return(last[0] == aim && last[1] == tomahawk && last[2] == diff); }); } catch (Exception e) { throw Bomb.toss("count never matched - last: " + O.toShortString(last), e); } }; publishAim(fvTopic, "QF.NDayBreak", "anything", "COMDTY", 3, "2009/07/01 14:00:00"); waitForCount(fv1C, 3, 0, -3); AreEqual(SystemStatus.RED, fakeGui.status(watcher.row("QF.NDayBreak", fv1C))); publishAim(fvTopic, "QF.NDayBreak", "anything", "COMDTY", 2, "2009/07/01 14:00:01"); waitForCount(fv1C, 2, 0, -2); AreEqual(SystemStatus.RED, fakeGui.status(watcher.row("QF.NDayBreak", fv1C))); publishAim(tuTopic, "QF.NDayBreak", "TOE", "COMDTY", 105, "2009/07/01 14:00:03"); waitForCount(tu1C, 105, 0, -105); AreEqual(SystemStatus.RED, fakeGui.status(watcher.row("QF.NDayBreak", tu1C))); publishAim(tuTopic, "QF.NDayBreak", "TOE", "COMDTY", 5, "2009/07/01 14:00:03"); waitForCount(tu1C, 5, 0, -5); AreEqual(SystemStatus.GREEN, fakeGui.status(watcher.row("QF.NDayBreak", tu1C))); publishAim(brokenTopic, "QF.NDayBreak", "BROKE", "COMDTY", 7, "2009/07/01 14:00:03"); fakeGui.waitMatches(7.0, () => watcher.firstRow()["aim"]); AreEqual(SystemStatus.RED, fakeGui.status(watcher.firstRow())); AreEqual(watcher.firstRow()["symbol"], "BROKE Comdty"); publishTomahawk(nday20, 11, "2009/07/01 14:00:04"); waitForCount(fv1C, 2, 11, 9); AreEqual(SystemStatus.RED, fakeGui.status(watcher.row("QF.NDayBreak", fv1C))); publishTomahawk(nday20, 2, "2009/07/01 14:00:04"); waitForCount(fv1C, 2, 2, 0); AreEqual(SystemStatus.GREEN, fakeGui.status(watcher.row("QF.NDayBreak", fv1C))); }