本文整理汇总了C#中MaterialType.Select方法的典型用法代码示例。如果您正苦于以下问题:C# MaterialType.Select方法的具体用法?C# MaterialType.Select怎么用?C# MaterialType.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaterialType
的用法示例。
在下文中一共展示了MaterialType.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AcceptTest
public void AcceptTest()
{
var offer = new MaterialType[] { MaterialType.Brick, MaterialType.Brick };
var request = new MaterialType[] { MaterialType.Wool, MaterialType.Grain };
var offeredMaterials = offer.Select(m => new RawMaterial(m)).ToArray();
var requestedMaterrials = request.Select(m => new RawMaterial(m)).ToArray();
var player1 = new Mock<IPlayer>();
player1.Setup(p => p.HasResources(offer)).Returns(true);
player1.Setup(p => p.TakeResources(offer)).Returns(offeredMaterials);
var player2 = new Mock<IPlayer>();
player2.Setup(p => p.HasResources(request)).Returns(true);
player2.Setup(p => p.TakeResources(request)).Returns(requestedMaterrials);
var trade = new Trade(offer, request, player1.Object);
trade.Accept(player2.Object);
player1.Verify(p => p.TakeResources(offer), Times.Once);
player2.Verify(p => p.TakeResources(request), Times.Once);
player1.Verify(p => p.AddResources(requestedMaterrials), Times.Once);
player2.Verify(p => p.AddResources(offeredMaterials), Times.Once);
Assert.Equal(TradeState.Processed, trade.State);
}