当前位置: 首页>>代码示例>>C#>>正文


C# Character.DropItem方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:mdamyanova,项目名称:Fundamental-Level,代码行数:32,代码来源:CharacterTests.cs

示例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);
            }
        }
开发者ID:ivailojordanov,项目名称:Fundamental-Level,代码行数:20,代码来源:CharacterTests.cs

示例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);
            }
        }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:21,代码来源:CharacterTests.cs


注:本文中的Character.DropItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。