public void UnsubscribeStopsEachTheOrderListener() { // Arrange var mockOrderListener = MockRepository.GenerateMock <IStreamingListener <OrderDTO> >(); var mockOrderListener2 = MockRepository.GenerateMock <IStreamingListener <OrderDTO> >(); _mockLsStreamingClientAccountConnection.Expect(x => x.BuildOrderListener(Arg <string> .Is.Anything)) .Return(mockOrderListener) .Repeat.Once(); _mockLsStreamingClientAccountConnection.Expect(x => x.BuildOrderListener(Arg <string> .Is.Anything)) .Return(mockOrderListener2) .Repeat.Once(); mockOrderListener.Expect(x => x.Stop()); mockOrderListener2.Expect(x => x.Stop()); // Act var orderStream = new OrderStream(_mockLsStreamingClientAccountConnection); //Two subscribtions orderStream.SubscribeToOrders(); orderStream.SubscribeToOrders(); orderStream.Unsubscribe(); // Assert _mockLsStreamingClientAccountConnection.VerifyAllExpectations(); mockOrderListener.VerifyAllExpectations(); mockOrderListener2.VerifyAllExpectations(); }
public IOrderStream <Order> Create() { var tradeUnsubscriberFactory = new UnsubscriberFactory <Order>(); var tradeOrderStream = new OrderStream <Order>(tradeUnsubscriberFactory); return(tradeOrderStream); }
public OrderStream Create(ILsStreamingClientAccountConnection lsCityindexStreamingClientConnection) { try { Log.Info("Creating order stream listener."); var orderStream = new OrderStream(lsCityindexStreamingClientConnection); return(orderStream); } catch (Exception ex) { Log.Error(ex); throw; } }
// 创建流事件 public bool CreateStreamFun(string key, List <float> clocks, params System.Action[] args) { // 如果该流重复,则不进行创建 if (GetStream(key) != null) { return(false); } OrderStream stream = new OrderStream(); stream.key = key; for (int i = 0; i < args.Length && i < clocks.Count; i++) { stream.clocks.Add(clocks[i]); stream.frames.Add((System.Action)args[i]); } m_OrderStreams.Add(stream); return(true); }
public void ValidSubscribtionsAreAddedToAToOrderStreamListenerList() { // Arrange var mockOrderListener = MockRepository.GenerateMock <IStreamingListener <OrderDTO> >(); _mockLsStreamingClientAccountConnection.Expect(x => x.BuildOrderListener(Arg <string> .Is.Anything)) .Return(mockOrderListener) .Repeat.Twice(); // Act var orderStream = new OrderStream(_mockLsStreamingClientAccountConnection); orderStream.SubscribeToOrders(); orderStream.SubscribeToOrders(); // Assert Assert.AreEqual(2, orderStream.Listeners.Count); _mockLsStreamingClientAccountConnection.VerifyAllExpectations(); mockOrderListener.VerifyAllExpectations(); }