public void Overflow() { _character.TempHp = 10; LooseTempHpCommand command = new LooseTempHpCommand(_character, 15); Assert.Throws <InvalidOperationException>(() => _mediator.Execute(command)); }
public void WrongUndo() { _character.TempHp = 10; LooseTempHpCommand command = new LooseTempHpCommand(_character, 10); Assert.Throws <NullReferenceException>(() => _mediator.Undo(command)); }
public void ReturnValue() { _character.TempHp = 10; LooseTempHpCommand command = new LooseTempHpCommand(_character, 10); IMediatorCommandResponse response = _mediator.Execute(command); NoResponse _response = response as NoResponse; Assert.IsNotNull(_response); }
private int handleTempHp(TakeDamageCommand command, PlayableEntity target, int remaining) { int amount = remaining < target.TempHp ? remaining : target.TempHp; LooseTempHpCommand inner_command = new LooseTempHpCommand(target, amount); _mediator.Value.Execute(inner_command); command.AddToInnerCommands(inner_command); return(remaining - amount); }
public void Full() { _character.TempHp = 10; LooseTempHpCommand command = new LooseTempHpCommand(_character, 10); _mediator.Execute(command); Assert.AreEqual(0, _character.TempHp); _mediator.Undo(command); Assert.AreEqual(10, _character.TempHp); }