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); }
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)); }
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); }
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); }
public void CantOpentNullTrade() { var market = new Market(); Assert.Throws<ArgumentNullException>(() => market.OpenTrade(null)); }