Beispiel #1
0
        public void ShowNewsResolvesPresenterAndCallsSetTickerSymbolOnItAndAddsNamedViewToRegion()
        {
            var regionManager = new MockRegionManager();
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var controller = new NewsController(regionManager, presenter, eventAggregator);

            controller.ShowNews("Test");

            Assert.IsNotNull(presenter.SetTickerSymbolArgumentCompanySymbol);
            Assert.AreEqual("Test", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
Beispiel #2
0
        public void ShouldNotifyReaderWhenCurrentNewsArticleChanges()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();
            var regionManager = new MockRegionManager();
            regionManager.Regions.Add("NewsRegion", new MockNewsRegion());
            var controller = new NewsController(regionManager, presenter, eventAggregator, newsReaderPresenter);

            controller.CurrentNewsArticleChanged(new NewsArticle() { Title = "SomeTitle", Body = "Newsbody" });

            Assert.IsTrue(newsReaderPresenter.SetNewsArticleCalled);
        }
        public void ShowNewsDoesNothingIfNewsFeedHasNoNews()
        {
            MockArticleView view = new MockArticleView();
            MockRegionManager regionManager = new MockRegionManager();
            regionManager.Regions.Add("NewsRegion", new MockNewsRegion());
            MockNewsFeedService newsFeedService = new MockNewsFeedService();
            newsFeedService.NewsArticles = null;
            ArticlePresentationModel presentationModel = new ArticlePresentationModel(view, newsFeedService);
            presentationModel.Controller = new MockNewsController();

            presentationModel.SetTickerSymbol("InexistentNews");

            Assert.AreEqual(0, ((MockNewsRegion)regionManager.Regions["NewsRegion"]).AddedViews.Count);
        }
Beispiel #4
0
        public void ControllerShowNewsWhenRasingGlobalEvent()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            var regionManager = new MockRegionManager();
            regionManager.Regions.Add("NewsRegion", new MockNewsRegion());
            var tickerSymbolSelectedEvent = new MockTickerSymbolSelectedEvent();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(tickerSymbolSelectedEvent);
            var controller = new NewsController(regionManager, presenter, eventAggregator);

            controller.Run();

            Assert.IsNotNull(tickerSymbolSelectedEvent.SubscribeArgumentAction);

            tickerSymbolSelectedEvent.SubscribeArgumentAction("TEST_SYMBOL");
            Assert.AreEqual("TEST_SYMBOL", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
Beispiel #5
0
        private MockRegionManager CreateRegionManager()
        {
            var regionManager = new MockRegionManager();
            regionManager.Regions.Add("SecondaryRegion", new MockRegion());
            regionManager.Regions.Add("NewsRegion", new MockRegion());
            regionManager.Regions.Add("ResearchRegion", new MockRegion());

            return regionManager;
        }