/// <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); }
/// <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()); }
public void DifficultyEnumHelperTests_ConvertStringToEnum_Average_Should_Pass() { // Arrange // Act var result = DifficultyEnumHelper.ConvertStringToEnum("Average"); // Reset // Assert Assert.AreEqual(DifficultyEnum.Average, result); }
public void DifficultyEnumHelperTests_ConvertStringToEnum_Unknown_Should_Pass() { // Arrange // Act var result = DifficultyEnumHelper.ConvertStringToEnum("Unknown"); // Reset // Assert Assert.AreEqual(DifficultyEnum.Unknown, result); }
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); } }