PageRenderTime 50ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 1ms

/V1/trunk/Source/StockTraderRI/StockTraderRI.Modules.Position.Tests/Mocks/MockNewsFeedService.cs

#
C# | 53 lines | 29 code | 8 blank | 16 comment | 0 complexity | 5425b2aea2b0d7f9fd626ca3795cc0db MD5 | raw file
  1. //===============================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation
  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 StockTraderRI.Infrastructure.Interfaces;
  22. using StockTraderRI.Infrastructure.Models;
  23. namespace StockTraderRI.Modules.Position.Tests.Mocks
  24. {
  25. public class MockNewsFeedService : INewsFeedService
  26. {
  27. readonly Dictionary<string, List<NewsArticle>> newsData = new Dictionary<string, List<NewsArticle>>();
  28. internal void UpdateNews(string tickerSymbol, NewsArticle newsArticle)
  29. {
  30. newsData.Add(tickerSymbol, new List<NewsArticle>() {newsArticle});
  31. Updated(this, new NewsFeedEventArgs(tickerSymbol,newsArticle.Title));
  32. }
  33. #region INewsFeedService Members
  34. public IList<NewsArticle> GetNews(string tickerSymbol)
  35. {
  36. throw new NotImplementedException();
  37. }
  38. public event EventHandler<NewsFeedEventArgs> Updated = delegate { };
  39. public bool HasNews(string tickerSymbol)
  40. {
  41. return newsData.ContainsKey(tickerSymbol);
  42. }
  43. #endregion
  44. }
  45. }