PageRenderTime 76ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/V1/trunk/Source/StockTraderRI/StockRI.Tests.AcceptanceTests/TestInfrastructure/DataProvider/MockModels/Order.cs

#
C# | 143 lines | 100 code | 15 blank | 28 comment | 2 complexity | e994e71e68158e5009e8427a258d3ce3 MD5 | raw file
  1. //===============================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation
  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.Xml.Serialization;
  20. using StockTraderRI.AcceptanceTests.Helpers;
  21. namespace StockTraderRI.AcceptanceTests.TestInfrastructure
  22. {
  23. [Serializable]
  24. [XmlRoot("Order")]
  25. public class Order
  26. {
  27. private string symbol;
  28. private decimal limitprice;
  29. private string orderType;
  30. private int shares;
  31. private string timeInForce;
  32. private string transactionType;
  33. public Order()
  34. { }
  35. /// <summary>
  36. /// Instantiate Order for symbol
  37. /// </summary>
  38. /// <param name="symbol">Symbol for which the model is created</param>
  39. public Order(string symbol)
  40. {
  41. this.symbol = symbol;
  42. }
  43. /// <summary>
  44. /// Instantiate Order with given parameter values
  45. /// </summary>
  46. /// <param name="symbol">Symbol for which the model is created</param>
  47. /// <param name="limitprice">Limit/Stop price for buying / selling the stock</param>
  48. /// <param name="orderType">type of the order</param>
  49. /// <param name="shares">number of shares to be bought / sold</param>
  50. /// <param name="timeInForce">time in force</param>
  51. public Order(string symbol, decimal limitPrice, string orderType, int shares, string timeInForce, string transactionType)
  52. {
  53. this.symbol = symbol;
  54. this.limitprice = limitPrice;
  55. this.orderType = orderType;
  56. this.shares = shares;
  57. this.timeInForce = timeInForce;
  58. this.transactionType = transactionType;
  59. }
  60. [XmlAttribute("TickerSymbol")]
  61. public string Symbol
  62. {
  63. get { return this.symbol; }
  64. set { this.symbol = value; }
  65. }
  66. [XmlAttribute("StopLimitPrice")]
  67. public decimal LimitStopPrice
  68. {
  69. get { return this.limitprice; }
  70. set { this.limitprice = value; }
  71. }
  72. [XmlAttribute("OrderType")]
  73. public string OrderType
  74. {
  75. get { return this.orderType; }
  76. set { this.orderType = value; }
  77. }
  78. [XmlAttribute("Shares")]
  79. public int NumberOfShares
  80. {
  81. get { return this.shares; }
  82. set { this.shares = value; }
  83. }
  84. [XmlAttribute("TimeInForce")]
  85. public string TimeInForce
  86. {
  87. get { return this.timeInForce; }
  88. set { this.timeInForce = value; }
  89. }
  90. public string FormattedTimeInForce
  91. {
  92. get
  93. {
  94. if (this.timeInForce == TestDataInfrastructure.GetTestInputData("TimeInForceEndOfDay"))
  95. {
  96. return TestDataInfrastructure.GetTestInputData("FormattedTimeInForceEndOfDay");
  97. }
  98. else
  99. {
  100. return String.Empty;
  101. }
  102. }
  103. set { this.timeInForce = value; }
  104. }
  105. [XmlAttribute("TransactionType")]
  106. public string TransactionType
  107. {
  108. get { return this.transactionType; }
  109. set { this.transactionType = value; }
  110. }
  111. public override bool Equals(object obj)
  112. {
  113. Order o = obj as Order;
  114. return (
  115. this.symbol.ToUpperInvariant().Equals(o.Symbol.ToUpperInvariant()) &&
  116. this.limitprice.Equals(o.LimitStopPrice) &&
  117. this.orderType.ToUpperInvariant().Equals(o.OrderType.ToUpperInvariant()) &&
  118. this.shares.Equals(o.NumberOfShares) &&
  119. this.timeInForce.ToUpperInvariant().Equals(o.TimeInForce.ToUpperInvariant()) &&
  120. this.transactionType.ToUpperInvariant().Equals(o.TransactionType.ToUpperInvariant())
  121. );
  122. }
  123. public override int GetHashCode()
  124. {
  125. return base.GetHashCode();
  126. }
  127. }
  128. }