コード例 #1
0
        public void UnsubscribeStopsEachThePriceListener()
        {
            // Arrange
            var mockPriceListener  = MockRepository.GenerateMock <IStreamingListener <PriceDTO> >();
            var mockPriceListener2 = MockRepository.GenerateMock <IStreamingListener <PriceDTO> >();

            _mockLsCityindexStreamingConnection.Expect(x => x.BuildPriceListener(Arg <string> .Is.Anything))
            .Return(mockPriceListener)
            .Repeat.Once();

            _mockLsCityindexStreamingConnection.Expect(x => x.BuildPriceListener(Arg <List <string> > .Is.Anything))
            .Return(mockPriceListener2)
            .Repeat.Once();

            mockPriceListener.Expect(x => x.Stop());
            mockPriceListener2.Expect(x => x.Stop());

            // Act
            var priceStream = new PriceStream(_mockLsCityindexStreamingConnection);

            priceStream.SubscribeToMarketPrice(new int());
            priceStream.SubscribeToMarketPriceList(new List <int>());
            priceStream.Unsubscribe();

            // Assert
            _mockLsCityindexStreamingConnection.VerifyAllExpectations();
            mockPriceListener.VerifyAllExpectations();
            mockPriceListener2.VerifyAllExpectations();
        }