Beispiel #1
0
        public void CantOpenTradeThatIsNotOpen(TradeState state)
        {
            var market = new Market();
            var trade = new Mock<ITrade>();
            trade.Setup(t => t.State).Returns(state);

            Assert.Throws<ArgumentException>(() => market.OpenTrade(trade.Object));
        }
Beispiel #2
0
        public void OpenTradeAddsToRequestList()
        {
            var market = new Market();
            var trade = new Mock<ITrade>();
            trade.Setup(t => t.State).Returns(TradeState.Open);

            market.OpenTrade(trade.Object);
            Assert.Contains(trade.Object, market.ActiveTrades);
        }
Beispiel #3
0
        public void OpentSameTradeTwiceGivesNoEffect()
        {
            var market = new Market();
            var trade = new Mock<ITrade>();
            trade.Setup(t => t.State).Returns(TradeState.Open);

            market.OpenTrade(trade.Object);
            market.OpenTrade(trade.Object);

            Assert.Contains(trade.Object, market.ActiveTrades);
            Assert.True(market.ActiveTrades.Count(r => r == trade.Object) == 1);
        }
Beispiel #4
0
        public void ActiveTradesOnlyShowesOpenTrades()
        {
            var market = new Market();
            var trade1 = new Mock<ITrade>();
            trade1.Setup(t => t.State).Returns(TradeState.Open);
            var trade2 = new Mock<ITrade>();
            trade2.Setup(t => t.State).Returns(TradeState.Open);
            var trade3 = new Mock<ITrade>();
            trade3.Setup(t => t.State).Returns(TradeState.Open);

            market.OpenTrade(trade1.Object);
            market.OpenTrade(trade2.Object);
            market.OpenTrade(trade3.Object);

            trade2.Setup(t => t.State).Returns(TradeState.Canceled);
            trade3.Setup(t => t.State).Returns(TradeState.Processed);

            Assert.Equal(new ITrade[] { trade1.Object }, market.ActiveTrades);
        }
Beispiel #5
0
 public void ActiveTradesIsEmptyListIfNoTrades()
 {
     var market = new Market();
     Assert.Equal(new ITrade[] { }, market.ActiveTrades);
 }
Beispiel #6
0
 public void CantOpentNullTrade()
 {
     var market = new Market();
     Assert.Throws<ArgumentNullException>(() => market.OpenTrade(null));
 }