Last active
March 5, 2017 20:05
-
-
Save charlieamat/6c49f32c93fb3ad55184b912bc139f86 to your computer and use it in GitHub Desktop.
Why is Unit Testing So Hard - Example 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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