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