예제 #1
0
        public void ApplyOnSkip_ShouldThrow_IfPassedICreaturesInBattleParameterIsNull()
        {
            ICreaturesInBattle creaturesInBattle = null;
            var addDefenseWhenSkip = new AddDefenseWhenSkip(5);

            var resultingException = Assert.Throws <ArgumentNullException>(() => addDefenseWhenSkip.ApplyOnSkip(creaturesInBattle));

            Assert.IsTrue(resultingException.Message.Contains("skipCreature"));
        }
예제 #2
0
        public void ApplyAfterDefending_ShouldNotChangeAnyICreaturesInBattleProperties()
        {
            var creaturesInBattle = new Mock <ICreaturesInBattle>(MockBehavior.Strict);

            var addDefenseWhenSkip = new AddDefenseWhenSkip(5);

            addDefenseWhenSkip.ApplyAfterDefending(creaturesInBattle.Object);

            creaturesInBattle.VerifyAll();
        }
예제 #3
0
        public void ApplyOnSkip_ShouldAssignTheCorrectValue_WhenPassedAValidParameter()
        {
            var expectedDefenseToAdd    = 5;
            var addDefenseWhenSkip      = new AddDefenseWhenSkip(expectedDefenseToAdd);
            var privateAddDefenseOnSkip = new msTest.PrivateObject(addDefenseWhenSkip);

            var actualValue = privateAddDefenseOnSkip.GetField("defenseToAdd");

            Assert.AreEqual(expectedDefenseToAdd, actualValue);
        }
예제 #4
0
        public void ReturnCorrectPermanentDefense_WhenApplyOnSkipIsCalled()
        {
            var defenceWhenSkip = new AddDefenseWhenSkip(2);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            defenceWhenSkip.ApplyOnSkip(creaturesInBattle);

            Assert.AreEqual(22, creaturesInBattle.PermanentDefense);
        }
예제 #5
0
        public void ApplyWhenDefending_ShouldNotChangeAnyICreaturesInBattleProperties()
        {
            var attacker = new Mock <ICreaturesInBattle>(MockBehavior.Strict);
            var defender = new Mock <ICreaturesInBattle>();

            var addDefenseWhenSkip = new AddDefenseWhenSkip(5);

            addDefenseWhenSkip.ApplyWhenDefending(attacker.Object, defender.Object);

            attacker.VerifyAll();
        }
예제 #6
0
        public void ApplyOnSkip_ShouldAccessICreaturesInBattlePermanentDefenseSetter()
        {
            var creaturesInBattle = new Mock <ICreaturesInBattle>();

            creaturesInBattle.SetupGet(creature => creature.PermanentDefense).Returns(0);
            creaturesInBattle.SetupSet(creature => creature.PermanentDefense = 0);

            var addDefenseWhenSkip = new AddDefenseWhenSkip(5);

            addDefenseWhenSkip.ApplyOnSkip(creaturesInBattle.Object);

            creaturesInBattle.Verify(creature => creature.PermanentDefense, Times.Once);
        }
예제 #7
0
        public void ReturnCorrectStringFormat_WhenToStringIsCalled()
        {
            var defenceWhenSkip = new AddDefenseWhenSkip(2);

            Assert.AreEqual("AddDefenseWhenSkip(2)", defenceWhenSkip.ToString());
        }
예제 #8
0
        public void ThrowArgumentNullException_ApplyOnSkipIsCalledWithNullCreature()
        {
            var defenceWhenSkip = new AddDefenseWhenSkip(2);

            Assert.Throws <ArgumentNullException>(() => defenceWhenSkip.ApplyOnSkip(null));
        }