private void createPREffect_Click(object sender, EventArgs e) { String resource = eventResource.SelectedValue.ToString(); int min, max; if (int.TryParse(minResource.Text, out min) && int.TryParse(maxResource.Text, out max)) { String prEffect = String.Format("{0}:{1}:{2}:{3}:{4}", PREventEffect.PR_EFFECT_TAG, resource, min, max, prResult.Text); if (PREventEffect.IsValidPREventEffect(prEffect)) { prEffectsList.Add(prEffect); } else { MessageBox.Show(this, prEffect); } } string toWrite = "PREFFECTS"; foreach (String ie in prEffectsList) { toWrite += "^" + ie; } WriteFile("prEffects.txt", toWrite); }
public void PREventEffect_ParseFromString() { PREventEffect pree = new PREventEffect(PREventEffect.PR_EFFECT_TAG + ":" + PlayerCharacter.HEALTH + ":0:0:Test Result"); String expectedPR = PlayerCharacter.HEALTH + ":0"; Assert.AreEqual(0, pree.GetMinimum(), "The min should be 0"); Assert.AreEqual(0, pree.GetMaximum(), "The max should be 0"); Assert.AreEqual(expectedPR, pree.GetResource().ParseToString(), "The string should match the expected value"); }
public void PREventEffect_StandardConstructor() { PREventEffect pree = new PREventEffect(); String expectedPR = PlayerCharacter.HEALTH + ":0"; Assert.AreEqual(0, pree.GetMinimum(), "The min should be 0"); Assert.AreEqual(0, pree.GetMaximum(), "The max should be 0"); Assert.AreEqual(expectedPR, pree.GetResource().ParseToString(), "The string should match the expected value"); }
public void PREventEffect_ParseToString() { String expected = PREventEffect.PR_EFFECT_TAG + ":" + PlayerCharacter.HEALTH + ":10:20:Test Result"; PREventEffect pree = new PREventEffect(expected); String expectedPR = PlayerCharacter.HEALTH + ":10"; Assert.AreEqual(10, pree.GetMinimum(), "The min should be 10"); Assert.AreEqual(20, pree.GetMaximum(), "The max should be 20"); Assert.AreEqual(expectedPR, pree.GetResource().ParseToString(), "The string should match the expected value"); Assert.AreEqual(expected, pree.ParseToString(), "String should be " + expected); }
public void PREventEffect_CheckStringValid() { foreach (Tuple <String, String> test in validStrings) { Assert.IsTrue(PREventEffect.IsValidPREventEffect(test.Item1), test.Item2); } foreach (Tuple <String, String> test in invalidStrings) { Assert.IsFalse(PREventEffect.IsValidPREventEffect(test.Item1), test.Item2); } }