示例#1
0
文件: MarketTest.cs 项目: Corne/VOC
        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);
        }
示例#2
0
文件: MarketTest.cs 项目: Corne/VOC
        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));
        }
示例#3
0
文件: MarketTest.cs 项目: Corne/VOC
        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);
        }
示例#4
0
文件: MarketTest.cs 项目: Corne/VOC
        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);
        }
示例#5
0
文件: MarketTest.cs 项目: Corne/VOC
 public void CantOpentNullTrade()
 {
     var market = new Market();
     Assert.Throws<ArgumentNullException>(() => market.OpenTrade(null));
 }