Skip to content

Instantly share code, notes, and snippets.

@charlieamat
Last active March 5, 2017 20:05
Show Gist options
  • Save charlieamat/6c49f32c93fb3ad55184b912bc139f86 to your computer and use it in GitHub Desktop.
Save charlieamat/6c49f32c93fb3ad55184b912bc139f86 to your computer and use it in GitHub Desktop.
Why is Unit Testing So Hard - Example 2
public class PlayerTest
{
[Test]
public void GetDamageFromWeapon()
{
var weapon = Substitute.For<Weapon>();
weapon.Damage.Returns(5.0);
Assert.AreEqual(5.0, new Player(weapon).Damage);
}
[Test]
public void GetDamageFromPlayer()
{
var player = Substitute.For<IPlayer>();
player.Damage.Returns(5.0);
Assert.AreEqual("Weapon Damage: 5", new PlayerView().WeaponLabelText());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment