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

/V2.2/trunk/RI/StockTraderRI.Tests.AcceptanceTest/StockTraderRI.Tests.AcceptanceTest/TestInfrastructure/DataProvider/ModuleDataProviders/MarketDataProvider.cs

#
C# | 59 lines | 38 code | 5 blank | 16 comment | 1 complexity | 8c3b2320fb8d78cb27b1befb1ac41855 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 System.Data;
22using StockTraderRI.Tests.AcceptanceTest.TestInfrastructure.MockModels;
23using System.Globalization;
24using AcceptanceTestLibrary.ApplicationHelper;
25
26namespace StockTraderRI.Tests.AcceptanceTest.TestInfrastructure
27{
28    public class MarketDataProvider : DataProviderBase<Market>
29    {
30        public MarketDataProvider()
31            : base()
32        { }
33
34        public override string GetDataFilePath()
35        {
36            return ConfigHandler.GetValue("MarketDataFile");
37        }
38
39        public override List<Market> GetData()
40        {
41            DataSet ds = new DataSet();
42            ds.Locale = CultureInfo.CurrentCulture;
43            ds.ReadXml(GetDataFilePath());
44            DataRow dr = null;
45
46            List<Market> market = new List<Market>();
47            for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
48            {
49                dr = ds.Tables[1].Rows[i];
50                market.Add(
51                    new Market(
52                        dr[TestDataInfrastructure.GetTestInputData("TickerSymbol")].ToString(), 
53                        decimal.Parse(dr[TestDataInfrastructure.GetTestInputData("LastPrice")].ToString(), CultureInfo.InvariantCulture)));
54            }
55
56            return market;
57        }
58    }
59}