本文整理汇总了C#中Character.DropItem方法的典型用法代码示例。如果您正苦于以下问题:C# Character.DropItem方法的具体用法?C# Character.DropItem怎么用?C# Character.DropItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character
的用法示例。
在下文中一共展示了Character.DropItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Character_Should_Drop_First_Item
public void Character_Should_Drop_First_Item()
{
// Arrange
var possibleItemDrops = new List<Item>
{
new Item("Axe", 25, 5),
new Item("Shield", 5, 50),
new Item("Resilience Potion", 0, 30)
};
// Act
var mock = new Mock<IRandomNumberProvider>();
//another way ->
//var mock = new Mock<Random>();
//mock.Setup(r => r.Next()).Returns(0);
// for (int i = 0; i < 1000; i++)
// {
// var num = mock.Object.Next(0);
// Assert.AreEqual(0, num);
// }
mock.Setup(r => r.GetRandomNumber(It.IsAny<int>(), It.IsAny<int>())).Returns(0);
var character = new Character(possibleItemDrops, mock.Object);
// Assert
for (int i = 0; i < 1000; i++)
{
var item = character.DropItem();
Assert.AreEqual("Axe", item.Name);
}
}
示例2: Character_Should_Drop_First_Item
public void Character_Should_Drop_First_Item()
{
// Arrange
var possibleItemDrops = new List<Item>
{
new Item("Axe", 25, 5),
new Item("Shield", 5, 50),
new Item("Resilience Potion", 0, 30)
};
// Act
var character = new Character(possibleItemDrops);
// Assert
for (int i = 0; i < 1000; i++)
{
var item = character.DropItem();
Assert.AreEqual("Axe", item.Name);
}
}
示例3: Character_Should_Drop_First_Item
public void Character_Should_Drop_First_Item()
{
// Arrange
var possibleItemDrops = new List<Item>
{
new Item("Axe", 25, 5),
new Item("Shield", 5, 50),
new Item("Resilience Potion", 0, 30)
};
var mockedRandomGenerator = new Mock<IRandomNumberProvider>();
mockedRandomGenerator.Setup(g => g.GetRandomNumber(It.IsAny<int>(), It.IsAny<int>())).Returns(0);
// Act
var character = new Character(possibleItemDrops, mockedRandomGenerator.Object);
// Assert
for (int i = 0; i < 1000; i++)
{
var item = character.DropItem();
Assert.AreEqual("Axe", item.Name);
}
}