/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. //===================================================================================
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using System.Text;
  21. using Microsoft.VisualStudio.TestTools.UnitTesting;
  22. using Moq;
  23. using StockTraderRI.Modules.News.Article;
  24. using StockTraderRI.Infrastructure.Models;
  25. using System.ComponentModel;
  26. namespace StockTraderRI.Modules.News.Tests.Article
  27. {
  28. [TestClass]
  29. public class NewsReaderViewModelFixture
  30. {
  31. [TestMethod]
  32. public void SetNewsArticleUpdatesProperty()
  33. {
  34. var target = new NewsReaderViewModel();
  35. bool propertyChangedRaised = false;
  36. target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
  37. {
  38. if (e.PropertyName == "NewsArticle")
  39. {
  40. propertyChangedRaised = true;
  41. }
  42. };
  43. NewsArticle article = new NewsArticle() { Title = "My Title", Body = "My Body" };
  44. target.NewsArticle = article;
  45. Assert.AreSame(article, target.NewsArticle);
  46. Assert.IsTrue(propertyChangedRaised);
  47. }
  48. }
  49. }