Example #1
0
        public void Overflow()
        {
            _character.TempHp = 10;
            LooseTempHpCommand command = new LooseTempHpCommand(_character, 15);

            Assert.Throws <InvalidOperationException>(() => _mediator.Execute(command));
        }
Example #2
0
        public void WrongUndo()
        {
            _character.TempHp = 10;
            LooseTempHpCommand command = new LooseTempHpCommand(_character, 10);

            Assert.Throws <NullReferenceException>(() => _mediator.Undo(command));
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }