Beispiel #1
0
 public void TestSellQuantityTooLarge()
 {
     Trade t = new Trade();
     t.Status = tradeStatus.Active;
     t.type = tradeTypes.Buy;
     t.quantity = 5;
     Assert.Throws<ArgumentException>(() => t.sell(10));
 }
Beispiel #2
0
        public void TestSell()
        {
            Symbol s = new Symbol("GOOG");
            Position pos = new Position();
            Trade t = new Trade();
            t.Status = tradeStatus.Active;
            t.type = tradeTypes.Buy;
            t.Position = pos;
            t.Symbol = s;
            t.timestamp = new DateTime(2013, 6, 1);
            t.price = 10;
            t.quantity = 5;

            Trade sell = t.sell(2);
            Assert.AreEqual(s, sell.Symbol);
            Assert.AreEqual(pos, sell.Position);
            Assert.AreEqual(tradeStatus.Closed, sell.Status);
            Assert.AreEqual(tradeTypes.Sell, sell.type);
            Assert.AreEqual(2, sell.quantity);
            Assert.AreNotEqual(t.timestamp, sell.timestamp);
            Assert.AreEqual(t, sell.RelatedTrade);
        }