本文整理匯總了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);
}
}