PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/V2.2/trunk/RI/Desktop/StockTraderRI.Modules.Position.Tests/Mocks/MockAccountPositionService.cs

#
C# | 63 lines | 34 code | 12 blank | 17 comment | 0 complexity | 5ece0a6e28f0b4db3ea2df94de2b14f6 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 StockTraderRI.Infrastructure.Interfaces;
  22. using StockTraderRI.Infrastructure.Models;
  23. namespace StockTraderRI.Modules.Position.Tests.Mocks
  24. {
  25. class MockAccountPositionService : IAccountPositionService
  26. {
  27. List<AccountPosition> positionData = new List<AccountPosition>();
  28. public void AddPosition(string ticker, decimal costBasis, long shares)
  29. {
  30. AddPosition(new AccountPosition(ticker, costBasis, shares));
  31. }
  32. public void AddPosition(AccountPosition position)
  33. {
  34. position.Updated += new EventHandler<AccountPositionEventArgs>(position_Updated);
  35. positionData.Add(position);
  36. //Notify that collection has changed
  37. Updated(this, new AccountPositionModelEventArgs(position));
  38. }
  39. void position_Updated(object sender, AccountPositionEventArgs e)
  40. {
  41. Updated(this, new AccountPositionModelEventArgs(sender as AccountPosition));
  42. }
  43. #region IAccountPositionService Members
  44. public IList<AccountPosition> GetAccountPositions()
  45. {
  46. return positionData;
  47. }
  48. public event EventHandler<AccountPositionModelEventArgs> Updated = delegate { };
  49. #endregion
  50. }
  51. }