/V2.2/trunk/RI/StockTraderRI.Tests.AcceptanceTest/StockTraderRI.Tests.AcceptanceTest/TestInfrastructure/DataProvider/MockModels/Order.cs

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