Ejemplo n.º 1
0
        public void VerifyConnected(VerifyFeed verify)
        {
            var expectedBrokerState = BrokerState.Connected;
            var expectedSymbolState = SymbolState.RealTime;
            var actualState         = verify.VerifyState(expectedBrokerState, expectedSymbolState, 600);

            Assert.IsTrue(actualState, "Expected " + expectedBrokerState + " and " + expectedSymbolState);
        }
Ejemplo n.º 2
0
        public void DemoStopSymbolTest()
        {
            using (VerifyFeed verify = Factory.Utility.VerifyFeed(symbol))
                using (Agent provider = CreateProvider()) {
                    verify.PauseSeconds = secondsDelay;
                    provider.SendEvent(new EventItem(verify, null, EventType.Connect, null));
                    log.Info("===DemoStopSymbolTest===");
                    if (debug)
                    {
                        log.Debug("===StartSymbol===");
                    }
                    provider.SendEvent(new EventItem(verify, symbol, EventType.StartSymbol, new StartSymbolDetail(TimeStamp.MinValue)));
                    if (debug)
                    {
                        log.Debug("===VerifyState===");
                    }
                    VerifyConnected(verify);
                    if (debug)
                    {
                        log.Debug("===VerifyFeed===");
                    }
                    long count = verify.Verify(2, assertTick, secondsDelay);
                    Assert.GreaterOrEqual(count, 2, "tick count");
                    if (debug)
                    {
                        log.Debug("===StopSymbol===");
                    }
                    provider.SendEvent(new EventItem(verify, symbol, EventType.StopSymbol));

                    // Wait for it to switch out of real time or historical mode.
                    var expectedBrokerState = BrokerState.Disconnected;
                    var expectedSymbolState = SymbolState.None;
                    var actualState         = verify.VerifyState(expectedBrokerState, expectedSymbolState, 25000);
                    Assert.IsTrue(actualState, "after receiving a StopSymbol event, if your provider plugin was sending ticks then it must return either respond with an EndHistorical or EndRealTime event. If it has already sent one of those prior to the StopSymbol, then no reponse is required.");

                    // Clean out and ignore any extra ticks.
                    count = verify.Verify(1000, assertTick, secondsDelay);
                    Assert.Less(count, 1000, "your provider plugin must not send any more ticks after receiving a StopSymbol event.");

                    // Make sure we don't get any more ticks.
                    count = verify.Verify(0, assertTick, secondsDelay);
                    Assert.AreEqual(0, count, "your provider plugin must not send any more ticks after receiving a StopSymbol event.");

                    provider.SendEvent(new EventItem(verify, EventType.Disconnect));
                    provider.SendEvent(new EventItem(verify, EventType.Terminate));
                }
        }