Ejemplo n.º 1
0
 public void hit_decreases_hp_properly()
 {
     var tank = new Tank();
     var initialHealth = tank.Health;
     tank.Hit(10);
     Assert.AreEqual(initialHealth-10, tank.Health);
 }
Ejemplo n.º 2
0
 public void hit_received_is_fired()
 {
     var tank = new Tank();
     bool eventFired = false;
     int healthAfterHit = 0;
     tank.HitReceived += (sender, currentHealth) =>
     {
         eventFired = true;
         healthAfterHit = currentHealth;
     };
     var initialHealth = tank.Health;
     const int hitVal = 50;
     tank.Hit(hitVal);
     Assert.That(eventFired);
     Assert.AreEqual(initialHealth-hitVal, healthAfterHit);
 }
Ejemplo n.º 3
0
 public void hp_equals_100_after_repairs()
 {
     var tank = new Tank();
     tank.Hit(96);
     _mechanic.Repair(tank);
     Assert.AreEqual(100, tank.Health);
 }
Ejemplo n.º 4
0
 public void cannot_fix_tank_with_hp_less_than_1()
 {
     var tank = new Tank();
     tank.Hit(tank.Health);
     Assert.Throws<Exception>(() => _mechanic.Repair(tank));
 }
Ejemplo n.º 5
0
 public void hp_cannot_be_negative()
 {
     var tank = new Tank();
     Assert.Throws<Exception>(() => tank.Hit(tank.Health*2));
 }