Пример #1
0
        public void ApplyAfterDefending_ShouldThrowWithCorrectMessage_IfDefenderWithSpecialtyParamenterIsNull()
        {
            ICreaturesInBattle defenderWithSpecialty = null;
            var specialty = new Resurrection();

            var exception = Assert.Throws <ArgumentNullException>(() => specialty.ApplyAfterDefending(defenderWithSpecialty));

            StringAssert.Contains("defenderWithSpecialty", exception.Message);
        }
Пример #2
0
        public void ReturnCorrectTotalHitPoints_WhenApplyAfterDefendingIsCalled()
        {
            var resurrection = new Resurrection();

            var angel = new Angel();

            var creaturesInBattle = new CreaturesInBattle(angel, 1);

            resurrection.ApplyAfterDefending(creaturesInBattle);

            Assert.AreEqual(200, creaturesInBattle.TotalHitPoints);
        }
Пример #3
0
        public void ApplyAfterDefending_ShouldNotSetDefenderWithSpecialtyTotalHitPoints_WhenTotalHitPointsAreLessThanOrEqualToZero()
        {
            var defenderWithSpecialty = new Mock <ICreaturesInBattle>();

            defenderWithSpecialty.SetupGet(mock => mock.TotalHitPoints).Returns(0);
            defenderWithSpecialty.SetupSet(mock => mock.TotalHitPoints = It.IsAny <int>());

            var specialty = new Resurrection();

            specialty.ApplyAfterDefending(defenderWithSpecialty.Object);

            defenderWithSpecialty.VerifySet(mock => mock.TotalHitPoints = It.IsAny <int>(), Times.Never());
        }
Пример #4
0
        public void AppleyAfterDefending_ShouldSetDefenderWithSpecialtyTotalHitPoiints_WhenTotalHitPointsIsLargerThanZero()
        {
            var stubCreature          = new FakeCreature();
            var defenderWithSpecialty = new Mock <ICreaturesInBattle>();

            defenderWithSpecialty.SetupGet(mock => mock.Count).Returns(1);
            defenderWithSpecialty.SetupGet(mock => mock.Creature).Returns(stubCreature);
            defenderWithSpecialty.SetupGet(mock => mock.TotalHitPoints).Returns(10);
            defenderWithSpecialty.SetupSet(mock => mock.TotalHitPoints = It.IsAny <int>());
            var specialty = new Resurrection();

            specialty.ApplyAfterDefending(defenderWithSpecialty.Object);

            defenderWithSpecialty.VerifySet(mock => mock.TotalHitPoints = It.IsAny <int>(), Times.Once());
        }
Пример #5
0
        public void ThrowArgumentNullException_WhenApplyAfterDefendingIsCalledWithNullDefender()
        {
            var resurrection = new Resurrection();

            Assert.Throws <ArgumentNullException>(() => resurrection.ApplyAfterDefending(null));
        }