PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms 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. 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.WatchList.Tests.Mocks
  24. {
  25. public class MockMarketFeedService : IMarketFeedService
  26. {
  27. public bool MockSymbolExists = true;
  28. public string SymbolExistsArgumentTickerSymbol;
  29. public Dictionary<string, decimal> feedData = new Dictionary<string, decimal>();
  30. internal void SetPrice(string tickerSymbol, decimal price)
  31. {
  32. feedData.Add(tickerSymbol, price);
  33. }
  34. #region IMarketFeedService Members
  35. public decimal GetPrice(string tickerSymbol)
  36. {
  37. if (!MockSymbolExists)
  38. throw new ArgumentException();
  39. if (feedData.ContainsKey(tickerSymbol))
  40. return feedData[tickerSymbol];
  41. else
  42. return 0m;
  43. }
  44. public long GetVolume(string tickerSymbol)
  45. {
  46. throw new NotImplementedException();
  47. }
  48. public event EventHandler Updated = delegate { };
  49. #endregion
  50. public bool SymbolExists(string tickerSymbol)
  51. {
  52. SymbolExistsArgumentTickerSymbol = tickerSymbol;
  53. return MockSymbolExists;
  54. }
  55. }
  56. }