PageRenderTime 67ms CodeModel.GetById 37ms RepoModel.GetById 0ms 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. //===================================================================================
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using System.Text;
  21. using System.Data;
  22. using StockTraderRI.Tests.AcceptanceTest.TestInfrastructure.MockModels;
  23. using System.Globalization;
  24. using AcceptanceTestLibrary.ApplicationHelper;
  25. namespace StockTraderRI.Tests.AcceptanceTest.TestInfrastructure
  26. {
  27. public class MarketDataProvider : DataProviderBase<Market>
  28. {
  29. public MarketDataProvider()
  30. : base()
  31. { }
  32. public override string GetDataFilePath()
  33. {
  34. return ConfigHandler.GetValue("MarketDataFile");
  35. }
  36. public override List<Market> GetData()
  37. {
  38. DataSet ds = new DataSet();
  39. ds.Locale = CultureInfo.CurrentCulture;
  40. ds.ReadXml(GetDataFilePath());
  41. DataRow dr = null;
  42. List<Market> market = new List<Market>();
  43. for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
  44. {
  45. dr = ds.Tables[1].Rows[i];
  46. market.Add(
  47. new Market(
  48. dr[TestDataInfrastructure.GetTestInputData("TickerSymbol")].ToString(),
  49. decimal.Parse(dr[TestDataInfrastructure.GetTestInputData("LastPrice")].ToString(), CultureInfo.InvariantCulture)));
  50. }
  51. return market;
  52. }
  53. }
  54. }