PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/V4/StockTrader RI/Desktop/StockTraderRI.Modules.News.Tests/Article/NewsReaderViewModelFixture.cs

#
C# | 53 lines | 33 code | 4 blank | 16 comment | 2 complexity | 42135938d29aa20f2d3b57fc447d180c MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using System;
18using System.Collections.Generic;
19using System.Linq;
20using System.Text;
21using Microsoft.VisualStudio.TestTools.UnitTesting;
22using Moq;
23using StockTraderRI.Modules.News.Article;
24using StockTraderRI.Infrastructure.Models;
25using System.ComponentModel;
26
27namespace StockTraderRI.Modules.News.Tests.Article
28{
29    [TestClass]
30    public class NewsReaderViewModelFixture
31    {
32        [TestMethod]
33        public void SetNewsArticleUpdatesProperty()
34        {
35            var target = new NewsReaderViewModel();
36
37            bool propertyChangedRaised = false;
38            target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
39            {
40                if (e.PropertyName == "NewsArticle")
41                {
42                    propertyChangedRaised = true;
43                }
44            };
45
46            NewsArticle article = new NewsArticle() { Title = "My Title", Body = "My Body" };
47            target.NewsArticle = article;
48
49            Assert.AreSame(article, target.NewsArticle);
50            Assert.IsTrue(propertyChangedRaised);
51        }
52    }
53}