PageRenderTime 27ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 1ms 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//===================================================================================
17using System;
18using System.Collections.Generic;
19using System.Linq;
20using System.Text;
21using StockTraderRI.Infrastructure.Interfaces;
22using StockTraderRI.Infrastructure.Models;
23
24namespace StockTraderRI.Modules.Position.Tests.Mocks
25{
26    class MockAccountPositionService : IAccountPositionService
27    {
28        List<AccountPosition> positionData = new List<AccountPosition>();
29
30        public void AddPosition(string ticker, decimal costBasis, long shares)
31        {
32            AddPosition(new AccountPosition(ticker, costBasis, shares));
33        }
34
35        public void AddPosition(AccountPosition position)
36        {
37            position.Updated += new EventHandler<AccountPositionEventArgs>(position_Updated);
38            positionData.Add(position);
39
40            //Notify that collection has changed
41            Updated(this, new AccountPositionModelEventArgs(position));
42        }
43
44        void position_Updated(object sender, AccountPositionEventArgs e)
45        {
46            Updated(this, new AccountPositionModelEventArgs(sender as AccountPosition));
47        }
48
49
50        #region IAccountPositionService Members
51
52        public IList<AccountPosition> GetAccountPositions()
53        {
54            return positionData;
55        }
56        
57        public event EventHandler<AccountPositionModelEventArgs> Updated = delegate { };
58
59        #endregion
60    }
61
62  
63}