示例#1
0
文件: AttackTest.cs 项目: rakot/rawr
        public void AvoidableByTest()
        {
            Attack target   = new Attack(); // Default is it avoidable by all.
            bool   expected = true;
            bool   actual;

            foreach (AVOIDANCE_TYPES at in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
            {
                foreach (AVOIDANCE_TYPES at2 in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
                {
                    if ((at | at2) == AVOIDANCE_TYPES.None)
                    {
                        expected = false;
                    }
                    else
                    {
                        expected = true;
                    }
                    actual = target.AvoidableBy(at | at2);
                    Assert.AreEqual(expected, actual, Enum.GetName(typeof(AVOIDANCE_TYPES), at | at2));
                }
            }
            target.SetUnavoidable();
            foreach (AVOIDANCE_TYPES at in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
            {
                foreach (AVOIDANCE_TYPES at2 in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
                {
                    if ((at | at2) == AVOIDANCE_TYPES.None)
                    {
                        expected = true;
                    }
                    else
                    {
                        expected = false;
                    }
                    actual = target.AvoidableBy(at | at2);
                    Assert.AreEqual(expected, actual, Enum.GetName(typeof(AVOIDANCE_TYPES), at | at2));
                }
            }
            // Set up individual flag values.
            target.Missable = true;
            foreach (AVOIDANCE_TYPES at in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
            {
                foreach (AVOIDANCE_TYPES at2 in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
                {
                    if ((at | at2) == AVOIDANCE_TYPES.Miss)
                    {
                        expected = true;
                    }
                    else
                    {
                        expected = false;
                    }
                    actual = target.AvoidableBy(at | at2);
                    Assert.AreEqual(expected, actual, Enum.GetName(typeof(AVOIDANCE_TYPES), at | at2));
                }
            }
            target.SetUnavoidable();

            target.Dodgable = true;
            foreach (AVOIDANCE_TYPES at in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
            {
                foreach (AVOIDANCE_TYPES at2 in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
                {
                    if ((at | at2) == AVOIDANCE_TYPES.Dodge)
                    {
                        expected = true;
                    }
                    else
                    {
                        expected = false;
                    }
                    actual = target.AvoidableBy(at | at2);
                    Assert.AreEqual(expected, actual, Enum.GetName(typeof(AVOIDANCE_TYPES), at | at2));
                }
            }
            target.SetUnavoidable();

            target.Parryable = true;
            foreach (AVOIDANCE_TYPES at in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
            {
                foreach (AVOIDANCE_TYPES at2 in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
                {
                    if ((at | at2) == AVOIDANCE_TYPES.Parry)
                    {
                        expected = true;
                    }
                    else
                    {
                        expected = false;
                    }
                    actual = target.AvoidableBy(at | at2);
                    Assert.AreEqual(expected, actual, Enum.GetName(typeof(AVOIDANCE_TYPES), at | at2));
                }
            }
            target.SetUnavoidable();

            target.Blockable = true;
            foreach (AVOIDANCE_TYPES at in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
            {
                foreach (AVOIDANCE_TYPES at2 in Enum.GetValues(typeof(AVOIDANCE_TYPES)))
                {
                    if ((at | at2) == AVOIDANCE_TYPES.Block)
                    {
                        expected = true;
                    }
                    else
                    {
                        expected = false;
                    }
                    actual = target.AvoidableBy(at | at2);
                    Assert.AreEqual(expected, actual, Enum.GetName(typeof(AVOIDANCE_TYPES), at | at2));
                }
            }
            target.SetUnavoidable();
        }