當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。