Exemplo 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);
        }
Exemplo n.º 2
0
        public void FromXMLTest()
        {
            AttackCollectionValue target = new AttackCollectionValue();
            bool caughtException         = false;

            try
            {
                target.FromXML(LoadableXML);
            }
            catch (System.Exception ex)
            {
                caughtException = true;
            }
            Assert.IsTrue(!caughtException, "Error creating FromXML");
            Assert.IsTrue(target.GetCurrentAttacks().Count == 3, "Incorrect Amount of attacks populated");
            Assert.IsTrue(target.GetCurrentPercentageApplied("Missile") == 100, "Incorrect Percentage Applied for Missile");

            target.FromXML("");
            Assert.IsTrue(target.GetCurrentAttacks().Count == 0, "Incorrect Amount of attacks populated");
            Assert.IsTrue(target.GetCurrentPercentageApplied("Missile") == 0, "Incorrect Percentage Applied for Missile");
        }
Exemplo n.º 3
0
        public void RemoveAttackTest1()
        {
            AttackCollectionValue target = new AttackCollectionValue();

            target.FromXML(LoadableXML);
            AttackCollectionValue.AttackValue attack = null;
            bool expected = true;
            bool actual;
            int  remainingCapabilityPercentage = 40;

            attack = target.GetCurrentAttacks()[1];
            actual = target.RemoveAttack(attack);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(remainingCapabilityPercentage, target.GetCurrentAttacks()[1].percentageApplied);
        }
Exemplo n.º 4
0
        public void RemoveAttackTest()
        {
            AttackCollectionValue target = new AttackCollectionValue();

            target.FromXML(LoadableXML);
            string capabilityName                = "Missile";
            string targetObjectId                = "MyTarget";
            string attackingObjectId             = "MyAttacker";
            int    attackStartTime               = 8;
            int    remainingCapabilityPercentage = 40;
            bool   expected = true;
            bool   actual;

            actual = target.RemoveAttack(capabilityName, targetObjectId, attackingObjectId, attackStartTime);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(remainingCapabilityPercentage, target.GetCurrentAttacks()[1].percentageApplied);
        }
Exemplo n.º 5
0
        public void GetCurrentPercentageAppliedTest()
        {
            AttackCollectionValue target = new AttackCollectionValue();
            string capabilityName        = "Missile";

            target.FromXML(LoadableXML);
            int expected = 100;
            int actual;

            actual = target.GetCurrentPercentageApplied(capabilityName);
            Assert.AreEqual(expected, actual);

            capabilityName = "Guns";
            expected       = 80;
            actual         = target.GetCurrentPercentageApplied(capabilityName);
            Assert.AreEqual(expected, actual);

            capabilityName = "Nonexistant";
            expected       = 0;
            actual         = target.GetCurrentPercentageApplied(capabilityName);
            Assert.AreEqual(expected, actual);
        }