Ejemplo n.º 1
0
        public void ToXMLTest()
        {
            AttackCollectionValue target = new AttackCollectionValue();
            target.FromXML(LoadableXML);
            string expected = LoadableXML;
            string actual;
            actual = target.ToXML();
            Assert.AreEqual(expected, actual);

        }
Ejemplo n.º 2
0
        public void AddAttackTest()
        {
            AttackCollectionValue target = new AttackCollectionValue();
            AttackCollectionValue.AttackValue attack = new AttackCollectionValue.AttackValue(8, 5, "MyTarget", "MyAttacker", "Missile", 60, false); 
            AttackCollectionValue.AttackValue secondAttack = new AttackCollectionValue.AttackValue(10, 5, "MyTarget", "MyAttacker", "Guns", 80, false);
            AttackCollectionValue.AttackValue thirdAttack = new AttackCollectionValue.AttackValue(11, 5, "MyTarget", "MyAttacker", "Missile", 60, false);
            string errorMessage = string.Empty; 
            string errorMessageExpected = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = true; 
            bool actual;
            //Add Attack 1
            actual = target.AddAttack(attack, out errorMessage);
            Assert.AreEqual(errorMessageExpected, errorMessage);
            Assert.AreEqual(expected, actual);

            //Add Attack 2
            actual = target.AddAttack(secondAttack, out errorMessage);
            Assert.AreEqual(errorMessageExpected, errorMessage);
            Assert.AreEqual(expected, actual);

            //Add Attack 3
            errorMessageExpected = "Applying 40% instead of 60%, as that's all available";
            actual = target.AddAttack(thirdAttack, out errorMessage);
            Assert.AreEqual(errorMessageExpected, errorMessage);
            Assert.AreEqual(expected, actual);
           
            //Add Attack 4
            AttackCollectionValue.AttackValue fourthAttack = new AttackCollectionValue.AttackValue(12, 5, "MyTarget", "MyAttacker", "Missile", 60, false);
            expected = false;
            errorMessageExpected = "There is no more available percentage to apply for this capability.  Try again later.";
            actual = target.AddAttack(thirdAttack, out errorMessage);
            Assert.AreEqual(errorMessageExpected, errorMessage);
            Assert.AreEqual(expected, actual);
            string serialized = target.ToXML();

            Assert.AreEqual(serialized, LoadableXML);
        }