PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/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
18using System;
19using System.Collections.Generic;
20using System.Linq;
21using System.Text;
22using StockTraderRI.Infrastructure.Interfaces;
23using StockTraderRI.Infrastructure.Models;
24
25namespace StockTraderRI.Modules.Position.Tests.Mocks
26{
27    public class MockNewsFeedService : INewsFeedService
28    {
29        readonly Dictionary<string, List<NewsArticle>> newsData = new Dictionary<string, List<NewsArticle>>();
30
31        internal void UpdateNews(string tickerSymbol, NewsArticle newsArticle)
32        {
33            newsData.Add(tickerSymbol, new List<NewsArticle>() {newsArticle});
34            Updated(this, new NewsFeedEventArgs(tickerSymbol,newsArticle.Title));
35        }
36
37        #region INewsFeedService Members
38
39        public IList<NewsArticle> GetNews(string tickerSymbol)
40        {
41            throw new NotImplementedException();
42        }
43
44        public event EventHandler<NewsFeedEventArgs> Updated = delegate { };
45
46        public bool HasNews(string tickerSymbol)
47        {
48            return newsData.ContainsKey(tickerSymbol);
49        }
50
51        #endregion
52    }
53}