public void ThrowArgumentNullException_WhenApplyWhenAttackingIsCalledWithNullDefender() { var reduceEnemyDefenseByPercentage = new ReduceEnemyDefenseByPercentage(2.5m); var creaturesInBattle = new CreaturesInBattle(new Angel(), 1); Assert.Throws <ArgumentNullException>(() => reduceEnemyDefenseByPercentage.ApplyWhenAttacking(creaturesInBattle, null)); }
public void ReturnCorrectDefenseChanges_WhenApplyWhenAttackingIsCalled() { var reduceEnemyDefenseByPercentage = new ReduceEnemyDefenseByPercentage(10m); var creaturesInBattle = new CreaturesInBattle(new Angel(), 1); reduceEnemyDefenseByPercentage.ApplyWhenAttacking(creaturesInBattle, creaturesInBattle); Assert.AreEqual(18, creaturesInBattle.CurrentDefense); }
public void Constructor_ShouldSetTheCorrectValueToPercentageField() { var expectedPercentage = 50m; var specialty = new ReduceEnemyDefenseByPercentage(expectedPercentage); var specialtyAsPrivateObject = new MSTest.PrivateObject(specialty); var actualPercentage = specialtyAsPrivateObject.GetProperty("Percentage"); Assert.AreEqual(expectedPercentage, actualPercentage); }
public void ApplyWhenAttacking_ShouldThrowWithCorrectMessage_IfDefenderParameterIsNull() { var attackerWithSpecialty = new Mock <ICreaturesInBattle>(); ICreaturesInBattle defender = null; var percentage = 50m; var specialty = new ReduceEnemyDefenseByPercentage(percentage); var exception = Assert.Throws <ArgumentNullException>(() => specialty.ApplyWhenAttacking(attackerWithSpecialty.Object, defender)); StringAssert.Contains("defender", exception.Message); }
public void ApplyWhenAttacking_ShouldSetDefenderCurrentDefense() { var attackerWithSpecialty = new Mock <ICreaturesInBattle>(); var defender = new Mock <ICreaturesInBattle>(); var percentage = 50m; var specialty = new ReduceEnemyDefenseByPercentage(percentage); defender.SetupGet(mock => mock.CurrentDefense).Returns(100); defender.SetupSet(mock => mock.CurrentDefense = It.IsAny <int>()); specialty.ApplyWhenAttacking(attackerWithSpecialty.Object, defender.Object); defender.VerifySet(mock => mock.CurrentDefense = It.IsAny <int>(), Times.Once()); }
public void ReturnCorrectStringFormat_WhenToStringIsCalled() { var reduceEnemyDefenseByPercentage = new ReduceEnemyDefenseByPercentage(2.5m); Assert.AreEqual("ReduceEnemyDefenseByPercentage(2.5)", reduceEnemyDefenseByPercentage.ToString()); }