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 NewsController(ArticleViewModel articleViewModel, NewsReaderViewModel newsReaderViewModel)
 {
     this.articleViewModel = articleViewModel;         
     this.newsReaderViewModel = newsReaderViewModel;
     if (articleViewModel != null)
     {
         this.articleViewModel.PropertyChanged += this.ArticleViewModel_PropertyChanged;
     }
 }
        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);
        }
Esempio n. 4
0
 public NewsReaderView(NewsReaderViewModel viewModel)
 {
     InitializeComponent();
     ViewModel = viewModel;
 }