void before_each() { bob = new Character(); bob.Name = "Bob"; bob.Alignment = AlignmentEnum.EVIL; }
void when_an_opponent_attacks() { context["if attack is successful"] = () => { Character jim = new Character(); act = () => jim.ApplyDamage(new AttackResult() { Success = true }); it["then character takes 1 point of damage"] = () => jim.HitPoints.should_be(4); it["then character takes 1 point of damage"] = () => jim.HitPoints.should_be(3); }; context["if attack is a critical hit"] = () => { Character jim = new Character(); act = () => jim.ApplyDamage(new AttackResult() { Success = true, IsCriticalHit = true }); it["then character takes 2 point of damage"] = () => jim.HitPoints.should_be(3); it["then character takes 2 point of damage again"] = () => jim.HitPoints.should_be(1); }; context["if attack is not successful"] = () => { act = () => bob.ApplyDamage(new AttackResult()); it["then character does not take damage"] = () => bob.HitPoints.should_be(5); }; context["given a character is near death"] = () => { before = () => joe = new Character(hitPoints: 1); context["when HitPoints are above zero"] = () => { before = () => joe = new Character(hitPoints: 3); act = () => joe.ApplyDamage(new AttackResult() { Success = true }); it["then character is alive"] = () => joe.IsAlive.should_be_true(); }; context["when HitPoints fall to zero"] = () => { act = () => joe.ApplyDamage(new AttackResult() { Success = true }); it["then character is dead"] = () => joe.IsAlive.should_be_false(); }; context["when HitPoints fall below zero"] = () => { act = () => joe.ApplyDamage(new AttackResult() { Success = true, IsCriticalHit = true }); it["then character is dead"] = () => joe.IsAlive.should_be_false(); }; }; }
void before_each() { bob = new Character(); }