public void TestIfHeroGainXP() { IWeapon weapon = new FakeWeapon(); ITarget target = new FakeTarget(); Hero hero = new Hero("Pesho", weapon); hero.Attack(target); int expectedResult = 10; int actualResult = hero.Experience; Assert.AreEqual(expectedResult, actualResult, "The value of gained XP is not correct!"); }
public void HeroGainsExperienceAfterAttackIfTargetDies() { // Arrange ITarget fakeTarget = new FakeTarget(); IWeapon fakeWeapon = new FakeWeapon(); Hero hero = new Hero(HeroName, fakeWeapon); // Act hero.Attack(fakeTarget); int expectedExperience = fakeTarget.GiveExperience(); // Assert Assert.AreEqual(expectedExperience, hero.Experience); }
public void AttackShouldNotChangeHeroExperienceWhenTargetIsAlive() { // Arrange var target = new Dummy(DeadTargetHealth + HealthIncrement, TargetExperience); var fakeWeapon = new FakeWeapon(WeaponAttackPoints, WeaponDurability); this.hero = new Hero(HeroName, fakeWeapon); // Act this.hero.Attack(target); // Assert Assert.AreEqual(this.heroInitialExperience, this.hero.Experience, "Hero experience should not change!"); }
public void AttackShouldAddTargetExperienceToHeroExperienceWhenTargetIsDead() { // Arrange var fakeTarget = new FakeDeadTarget(TargetExperience); var fakeWeapon = new FakeWeapon(WeaponAttackPoints, WeaponDurability); this.hero = new Hero(HeroName, fakeWeapon); // Act this.hero.Attack(fakeTarget); // Assert Assert.AreEqual(this.heroInitialExperience + TargetExperience, this.hero.Experience, "Hero does not gain target experience!"); }
public void HeroGainsExperienceAfterAttackIfTargetDies() { // Arrange ITarget fakeTarget = new FakeTarget(); IWeapon fakeWeapon = new FakeWeapon(); Hero hero = new Hero(HeroName, fakeWeapon); // Act var xp = hero.Experience; hero.Attack(fakeTarget); // Assert Assert.IsTrue(hero.Experience > xp); }
public void Hero_Should_Get_Exp_If_The_Target_Is_Dead() { // WITH FAKE CLASSES! // Arrange var weapon = new FakeWeapon(); var target = new FakeTarget(); var hero = new Hero("Stavri", weapon); // Act hero.Attack(target); // Assert Assert.That(hero.Experience, Is.EqualTo(FakeTarget.DEFAULT_EXP)); }
public void HeroGainsExperienceAfterAttackIfTargetDies() { // Arrange ITarget fakeTarget = new FakeTarget(); IWeapon fakeWeapon = new FakeWeapon(); Hero hero = new Hero(HeroName, fakeWeapon); // Act hero.Attack(fakeTarget); // Assert Assert.That(hero.Experience, Is.EqualTo(0)); // Act hero.Attack(fakeTarget); // Assert Assert.That(hero.Experience, Is.EqualTo(fakeTarget.GiveExperience())); }
public void HeroShouldIncreaseExperienceIfTargetIsDead() { Hero hero = new Hero("Spiderman"); int health = 0; int experience = 40; FakeTarget fakeTarget = new FakeTarget(health, experience); int attackPoints = 10; int durabilityPoints = 20; var givenXP = fakeTarget.GiveExperience(); //this.experience += target.GiveExperience(); FakeWeapon fakeWeapon = new FakeWeapon(attackPoints, durabilityPoints); hero.Attack(fakeTarget); int expectedXP = 40 + givenXP; Assert.AreEqual(expectedXP, hero.Experience); }
public void AttackShouldNotChangeHeroExperienceWhenTargetIsAlive_Mock() { // Arrange var fakeTarget = new Mock <ITarget>(); fakeTarget .Setup(t => t.IsDead()) .Returns(false); fakeTarget .Setup(t => t.GiveExperience()) .Callback(() => throw new InvalidOperationException("Dummy is dead.")); var fakeWeapon = new FakeWeapon(WeaponAttackPoints, WeaponDurability); this.hero = new Hero(HeroName, fakeWeapon); // Act this.hero.Attack(fakeTarget.Object); // Assert Assert.AreEqual(this.heroInitialExperience, this.hero.Experience, "Hero experience should not change!"); }