コード例 #1
0
ファイル: RandomPlayerHelper.cs プロジェクト: yf23/GameBase
        /// <summary>
        /// Get A Random Difficulty
        /// </summary>
        /// <returns></returns>
        public static DifficultyEnum GetMonsterDifficultyValue()
        {
            var DifficultyList = DifficultyEnumHelper.GetListMonster;

            var RandomDifficulty = DifficultyList.ElementAt(DiceHelper.RollDice(1, DifficultyList.Count()) - 1);

            var result = DifficultyEnumHelper.ConvertStringToEnum(RandomDifficulty);

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// The Level selected from the list
        /// Need to recalculate Max Health
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void Difficulty_Changed(object sender, EventArgs args)
        {
            // Check for null, SelectedItem is not set when the control is created
            if (DifficultyPicker.SelectedItem == null)
            {
                return;
            }

            // Change the Difficulty
            ViewModel.Data.Difficulty = DifficultyEnumHelper.ConvertStringToEnum(DifficultyPicker.SelectedItem.ToString());
        }
コード例 #3
0
        public void DifficultyEnumHelperTests_ConvertStringToEnum_Average_Should_Pass()
        {
            // Arrange

            // Act
            var result = DifficultyEnumHelper.ConvertStringToEnum("Average");

            // Reset

            // Assert
            Assert.AreEqual(DifficultyEnum.Average, result);
        }
コード例 #4
0
        public void DifficultyEnumHelperTests_ConvertStringToEnum_Unknown_Should_Pass()
        {
            // Arrange

            // Act
            var result = DifficultyEnumHelper.ConvertStringToEnum("Unknown");

            // Reset

            // Assert
            Assert.AreEqual(DifficultyEnum.Unknown, result);
        }
コード例 #5
0
        public void DifficultyEnumHelper_ConvertStringToEnum_Should_Pass()
        {
            // Arrange

            var myList = Enum.GetNames(typeof(DifficultyEnum)).ToList();

            DifficultyEnum myActual;
            DifficultyEnum myExpected;

            // Act

            foreach (var item in myList)
            {
                myActual   = DifficultyEnumHelper.ConvertStringToEnum(item);
                myExpected = (DifficultyEnum)Enum.Parse(typeof(DifficultyEnum), item);

                // Assert
                Assert.AreEqual(myExpected, myActual, "string: " + item + TestContext.CurrentContext.Test.Name);
            }
        }