PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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