PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/V1/trunk/Source/StockTraderRI/StockTraderRI.Modules.WatchList.Tests/Mocks/MockMarketFeedService.cs

#
C# | 67 lines | 40 code | 11 blank | 16 comment | 2 complexity | b14d138e095f00764aac9b56eec03823 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.WatchList.Tests.Mocks
26{
27    public class MockMarketFeedService : IMarketFeedService
28    {
29        public bool MockSymbolExists = true;
30        public string SymbolExistsArgumentTickerSymbol;
31
32        public Dictionary<string, decimal> feedData = new Dictionary<string, decimal>();
33
34        internal void SetPrice(string tickerSymbol, decimal price)
35        {
36            feedData.Add(tickerSymbol, price);
37        }
38
39        #region IMarketFeedService Members
40
41        public decimal GetPrice(string tickerSymbol)
42        {
43            if (!MockSymbolExists)
44                throw new ArgumentException();
45
46            if (feedData.ContainsKey(tickerSymbol))
47                return feedData[tickerSymbol];
48            else
49                return 0m;
50        }
51
52        public long GetVolume(string tickerSymbol)
53        {
54            throw new NotImplementedException();
55        }
56
57        public event EventHandler Updated = delegate { };
58
59        #endregion
60
61        public bool SymbolExists(string tickerSymbol)
62        {
63            SymbolExistsArgumentTickerSymbol = tickerSymbol;
64            return MockSymbolExists;
65        }
66    }
67}