PageRenderTime 28ms CodeModel.GetById 20ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/V4/StockTrader RI/StockTraderRI.Tests.AcceptanceTest/StockTraderRI.Tests.AcceptanceTest/TestInfrastructure/DataProvider/ModuleDataProviders/OrderDataProvider.cs

#
C# | 67 lines | 44 code | 7 blank | 16 comment | 2 complexity | 3e0e283369789ad93468fd9f4d936605 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.Data;
19using System.Collections.Generic;
20using System.IO;
21using System.Globalization;
22using AcceptanceTestLibrary.ApplicationHelper;
23
24
25namespace StockTraderRI.Tests.AcceptanceTest.TestInfrastructure
26{
27    public class OrderDataProvider : DataProviderBase<Order>
28    {
29        public OrderDataProvider()
30            : base()
31        { }
32
33        public override string GetDataFilePath()
34        {
35            return ConfigHandler.GetValue("OrderProcessingFile");
36        }
37
38        public override List<Order> GetData()
39        {
40            List<Order> order = new List<Order>();
41            string filepath = GetDataFilePath();
42
43            if (File.Exists(filepath))
44            {
45                DataSet ds = new DataSet();
46                ds.Locale = CultureInfo.CurrentCulture;
47                ds.ReadXml(filepath);
48                DataRow dr = null;
49
50
51                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
52                {
53                    dr = ds.Tables[0].Rows[i];
54                    order.Add(
55                        new Order(dr["TickerSymbol"].ToString(),
56                        decimal.Parse(dr["StopLimitPrice"].ToString(), CultureInfo.InvariantCulture),
57                        dr["OrderType"].ToString(),
58                        int.Parse(dr["Shares"].ToString(), CultureInfo.InvariantCulture),
59                        dr["TimeInForce"].ToString(),
60                        dr["TransactionType"].ToString())
61                        );
62                }
63            }
64            return order;
65        }
66    }
67}