public void CanInitPresenter() { MockArticleView view = new MockArticleView(); MockNewsFeedService newsFeedService = new MockNewsFeedService(); ArticlePresentationModel presentationModel = new ArticlePresentationModel(view, newsFeedService); Assert.AreEqual<IArticleView>(view, presentationModel.View); }
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); }
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); }
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); }
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); }
public void ArticlePresenterCallControllerToShowNewsReader() { var view = new MockArticleView(); var newsFeedService = new MockNewsFeedService(); var mockController = new MockNewsController(); var presenter = new ArticlePresentationModel(view, newsFeedService); presenter.Controller = mockController; view.RaiseShowNewsReaderEvent(); Assert.IsTrue(mockController.ShowNewsReaderCalled); }