Ejemplo n.º 1
0
        public void ShouldUpdateModelWithDataFromServiceOnTickerSymbolSelected()
        {
            var historyService = new MockMarketHistoryService();
            var tickerSymbolSelected = new MockTickerSymbolSelectedEvent();
            var eventAggregator = new Mock<IEventAggregator>();
            eventAggregator.Setup(x => x.GetEvent<TickerSymbolSelectedEvent>()).Returns(
                tickerSymbolSelected);

            TrendLineViewModel presentationModel = new TrendLineViewModel(historyService, eventAggregator.Object);

            tickerSymbolSelected.SubscribeArgumentAction("MyTickerSymbol");

            Assert.IsTrue(historyService.GetPriceHistoryCalled);
            Assert.AreEqual("MyTickerSymbol", historyService.GetPriceHistoryArgument);
            Assert.IsNotNull(presentationModel.HistoryCollection);
            Assert.AreEqual(historyService.Data.Count, presentationModel.HistoryCollection.Count);
            Assert.AreEqual(historyService.Data[0], presentationModel.HistoryCollection[0]);
            Assert.AreEqual("MyTickerSymbol", presentationModel.TickerSymbol);
        }
        public void ShouldUpdateModelWithDataFromServiceOnTickerSymbolSelected()
        {
            var historyService       = new MockMarketHistoryService();
            var tickerSymbolSelected = new MockTickerSymbolSelectedEvent();
            var eventAggregator      = new Mock <IEventAggregator>();

            eventAggregator.Setup(x => x.GetEvent <TickerSymbolSelectedEvent>()).Returns(
                tickerSymbolSelected);

            TrendLineViewModel viewModel = new TrendLineViewModel(historyService, eventAggregator.Object);

            tickerSymbolSelected.SubscribeArgumentAction("MyTickerSymbol");

            Assert.IsTrue(historyService.GetPriceHistoryCalled);
            Assert.AreEqual("MyTickerSymbol", historyService.GetPriceHistoryArgument);
            Assert.IsNotNull(viewModel.HistoryCollection);
            Assert.AreEqual(historyService.Data.Count, viewModel.HistoryCollection.Count);
            Assert.AreEqual(historyService.Data[0], viewModel.HistoryCollection[0]);
            Assert.AreEqual("MyTickerSymbol", viewModel.TickerSymbol);
        }