public void GivenMap_WhenShootingWeaponAtOwnMap_ThrowsException() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var weapon = new WeaponStub(this.player); Assert.Throws <InvalidOperationException>(() => map.Shoot(coordinate, weapon)); }
public void GivenMap_WhenShootingWeaponAtCoordinatesOutsideOfMap_ThrowsException() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(-1, -1); var otherPlayer = new BattleshipPlayer("OtherPlayer", 'A', PlayerType.One); var weapon = new WeaponStub(otherPlayer); Assert.Throws <ArgumentException>(() => map.Shoot(coordinate, weapon)); }
public void GivenMap_WhenShootingWeaponAtCoordinatesInMap_CallsShootOnWeapon() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var otherPlayer = new BattleshipPlayer("OtherPlayer", 'A', PlayerType.One); var weapon = new WeaponStub(otherPlayer); map.Shoot(coordinate, weapon); Assert.True(weapon.ShootCalled); Assert.NotNull(weapon.Target); }
public void PlayerDamageComputationIsCorrectStub() { // Arrange Player player = new Player(); float multiplier = 2.0f; IWeapon weapon = new WeaponStub(); player.Equip(weapon); // Act float actualResult = player.Damage(multiplier); // Assert Assert.That(actualResult, Is.EqualTo(weapon.Damage() * multiplier)); }