コード例 #1
0
        public void ShowNewsPassesNewsContentToView()
        {
            MockArticleView view = new MockArticleView();
            MockNewsFeedService newsFeedService = new MockNewsFeedService();
            newsFeedService.NewsArticles = new List<NewsArticle>() { new NewsArticle() { Title = "FUND0", Body = "My custom body text" } };
            ArticlePresentationModel presentationModel = new ArticlePresentationModel(view, newsFeedService);
            presentationModel.Controller = new MockNewsController();

            presentationModel.SetTickerSymbol("FUND0");

            Assert.AreEqual("My custom body text", ((NewsArticle)view.Model.Articles.CurrentItem).Body);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void ViewContainsCorrectModelHeaderInfoAfterSetTickerSymbol()
        {
            var view = new MockArticleView();
            var newsFeedService = new MockNewsFeedService();
            newsFeedService.NewsArticles = new List<NewsArticle>() { new NewsArticle() { Title = "MySymbol", IconUri = "MyPath" } };
            var presenter = new ArticlePresentationModel(view, newsFeedService);
            presenter.Controller = new MockNewsController();

            presenter.SetTickerSymbol("MyTitle");

            Assert.IsNotNull(view.Model);
            Assert.IsNotNull(view.Model.Articles);
            Assert.AreEqual("MyPath", ((NewsArticle)view.Model.Articles.CurrentItem).IconUri);
            Assert.AreEqual("MySymbol", ((NewsArticle)view.Model.Articles.CurrentItem).Title);
        }
コード例 #4
0
        public void ArticlePresenterNotifiesControllerOnItemChange()
        {
            var view = new MockArticleView();
            var newsFeedService = new MockNewsFeedService();
            var mockController = new MockNewsController();
            newsFeedService.NewsArticles = new List<NewsArticle>() { new NewsArticle() { Title = "MySymbol", IconUri = "MyPath" },
                                                                     new NewsArticle() { Title = "OtherSymbol", IconUri = "OtherPath" }};
            var presenter = new ArticlePresentationModel(view, newsFeedService);
            presenter.Controller = mockController;
            presenter.SetTickerSymbol("DoesNotMatter");

            presenter.Articles.MoveCurrentToNext();

            Assert.IsTrue(mockController.CurrentItemWasCalled);
        }