public void ShouldValidateWhenCommandIsValid() { var command = new LendCommand() { IdGame = Guid.NewGuid(), IdFriend = Guid.NewGuid() }; Assert.True(command.Valid()); }
public void ShouldLendGameWhenCommandIsValid() { var command = new LendCommand() { IdFriend = Guid.NewGuid(), IdGame = Guid.NewGuid() }; var result = _handler.Handle(command); Assert.NotEqual(null, result); Assert.True(_handler.Valid); }
public ICommandResult Handle(LendCommand command) { var game = _repository.Get(command.IdGame); var friend = _friendRepository.Get(command.IdFriend); var loan = new Loan(friend); game.Lend(loan); AddNotifications(game.Notifications); if (Invalid) { return(ErrorResult()); } _repository.Update(game); return(new GameCommandResult(true, "Jogo emprestado com sucesso", game.Id)); }
public async Task <ICommandResult> Post([FromBody] LendCommand command) { var result = _handler.Handle(command); return(await Response(result)); }