public ICommandResult Handle(ConfirmeReservaCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados incorretos", command.Notifications)); } var reserva = _reservaRepository.GetById(command.ReservaId); reserva.Pagar(); _reservaRepository.Update(reserva); return(new GenericCommandResult(true, "Pagamento realizado, Reserva confirmada")); }
public void Dado_um_ConfirmeReservaCommand_valido_a_reserva_deve_ser_confirmada() { var cliente = _clientRepository.GetById(Guid.NewGuid()); var sessao = _sessaoRepository.GetById(Guid.NewGuid()); var reserva = new Reserva(cliente, sessao); reserva.AdicionarIngresso(new Ingresso("Jose", sessao.Poltrona[0])); _reservaRepository.Add(reserva); var command = new ConfirmeReservaCommand(reserva.Id); var commandResult = (GenericCommandResult)_handler.Handle(command); Assert.IsTrue(commandResult.Sucess); Assert.AreEqual(reserva.Status, EStatusReserva.PagamentoConcluido); }