public void WhenArticleViewModelSelectedArticleChanged_NewsReaderViewModelNewsArticleUpdated()
        {
            // Prepare
            INewsFeedService newsFeedService = new Mock<INewsFeedService>().Object;
            IRegionManager regionManager = new Mock<IRegionManager>().Object;

            var tickerSymbolSelectedEvent = new Mock<TickerSymbolSelectedEvent>().Object;

            var mockEventAggregator = new Mock<IEventAggregator>();
            mockEventAggregator.Setup(x => x.GetEvent<TickerSymbolSelectedEvent>()).Returns(tickerSymbolSelectedEvent);
            IEventAggregator eventAggregator = mockEventAggregator.Object;


            ArticleViewModel articleViewModel = new ArticleViewModel(newsFeedService, regionManager, eventAggregator);
            NewsReaderViewModel newsReaderViewModel = new NewsReaderViewModel();

            var controller = new NewsController(articleViewModel, newsReaderViewModel);

            NewsArticle newsArticle = new NewsArticle() { Title = "SomeTitle", Body = "Newsbody" };

            // Act
            articleViewModel.SelectedArticle = newsArticle;

            // Verify
            Assert.AreSame(newsArticle, newsReaderViewModel.NewsArticle);
        }
        public void SetNewsArticlesSetsViewModel()
        {
            var view = new MockNewsReaderView();

            var presenter = new NewsReaderPresenter(view);

            NewsArticle article = new NewsArticle() { Title = "My Title", Body = "My Body" };
            presenter.SetNewsArticle(article);

            Assert.AreSame(article, view.Model);
        }
        public void SetNewsArticleUpdatesProperty()
        {
            var target = new NewsReaderViewModel();

            bool propertyChangedRaised = false;
            target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "NewsArticle")
                {
                    propertyChangedRaised = true;
                }
            };

            NewsArticle article = new NewsArticle() { Title = "My Title", Body = "My Body" };
            target.NewsArticle = article;

            Assert.AreSame(article, target.NewsArticle);
            Assert.IsTrue(propertyChangedRaised);
        }
Exemplo n.º 4
0
 public void SetNewsArticle(NewsArticle article)
 {
     this.view.Model = article;
 }
 public void SetNewsArticle(NewsArticle article)
 {
     readerView.Model = article;
 }
Exemplo n.º 6
0
 public void CurrentNewsArticleChanged(NewsArticle article)
 {
     this.readerPresenter.SetNewsArticle(article);
 }
Exemplo n.º 7
0
 public void SetNewsArticle(NewsArticle article)
 {
     SetNewsArticleCalled = true;
 }
Exemplo n.º 8
0
 public void CurrentNewsArticleChanged(NewsArticle article)
 {
     CurrentItemWasCalled = true;
 }
Exemplo n.º 9
0
        public void WhenShowNewsReaderCommandInvokes_RegionIsNavigated()
        {
            // Prepare
            NewsArticle newsArticle = new NewsArticle();

            var tickerSymbolSelectedEvent = new Mock<TickerSymbolSelectedEvent>().Object;

            Mock<INewsFeedService> mockNewsFeedService = new Mock<INewsFeedService>();
            Mock<IRegionManager> mockRegionManager = new Mock<IRegionManager>();
            Mock<IEventAggregator> mockEventAggregator = new Mock<IEventAggregator>();
            mockEventAggregator.Setup(x => x.GetEvent<TickerSymbolSelectedEvent>()).Returns(tickerSymbolSelectedEvent);

            INewsFeedService newsFeedService = mockNewsFeedService.Object;
            IRegionManager regionManager = mockRegionManager.Object;
            IEventAggregator eventAggregator = mockEventAggregator.Object;

            ArticleViewModel target = new ArticleViewModel(newsFeedService, regionManager, eventAggregator);

            bool propertyChangedRaised = false;
            target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "SelectedArticle")
                {
                    propertyChangedRaised = true;
                }
            };

            // Act
            target.SelectedArticle = newsArticle;

            // Verify
            Assert.AreEqual(newsArticle, target.SelectedArticle);
            Assert.IsTrue(propertyChangedRaised);
        }
Exemplo n.º 10
0
 internal void UpdateNews(string tickerSymbol, NewsArticle newsArticle)
 {
     newsData.Add(tickerSymbol, new List<NewsArticle>() {newsArticle});
     Updated(this, new NewsFeedEventArgs(tickerSymbol,newsArticle.Title));
 }
Exemplo n.º 11
0
 public void CurrentNewsArticleChanged(NewsArticle article)
 {
     this.CurrentNewsArticleChangedCalled = true;
 }