public void TraducirDTOApuestaJugadorTest() { DTOApuestaJugador _dtoEsperado = FabricaDTO.CrearDtoApuestaJugador(); Jugador _jugador = FabricaEntidades.CrearJugador(); _jugador.Id = 1; _dtoEsperado.IdLogro = 1; _dtoEsperado.IdUsuario = 1; _dtoEsperado.IdJugador = 1; _dtoEsperado.Estado = "en curso"; _apuestaJugador = FabricaEntidades.CrearApuestaJugador(); _apuestaJugador.Logro = _logroJugador; _apuestaJugador.Usuario = _apostador; _apuestaJugador.Respuesta = _jugador; _apuestaJugador.Estado = "en curso"; _traductorApuestaJugador = FabricaTraductor.CrearTraductorApuestaJugador(); _dtoApuestaJugador = _traductorApuestaJugador.CrearDto(_apuestaJugador); Assert.AreEqual(_dtoEsperado.IdLogro, _dtoApuestaJugador.IdLogro); Assert.AreEqual(_dtoEsperado.IdUsuario, _dtoApuestaJugador.IdUsuario); Assert.AreEqual(_dtoEsperado.IdJugador, _dtoApuestaJugador.IdJugador); Assert.AreEqual(_dtoEsperado.Estado, _dtoApuestaJugador.Estado); }
public void TraducirApuestaJugadorTest() { ApuestaJugador _apuestaEsperada = FabricaEntidades.CrearApuestaJugador(); Jugador _jugador = FabricaEntidades.CrearJugador(); _jugador.Id = 1; _apuestaEsperada.Respuesta = _jugador; _apuestaEsperada.Logro = _logroJugador; _apuestaEsperada.Usuario = _apostador; _dtoApuestaJugador = FabricaDTO.CrearDtoApuestaJugador(); _dtoApuestaJugador.IdLogro = 1; _dtoApuestaJugador.IdUsuario = 1; _dtoApuestaJugador.IdJugador = 1; _traductorApuestaJugador = FabricaTraductor.CrearTraductorApuestaJugador(); _apuestaJugador = _traductorApuestaJugador.CrearEntidad(_dtoApuestaJugador) as ApuestaJugador; Assert.AreEqual(_apuestaEsperada.Logro.Id, _apuestaJugador.Logro.Id); Assert.AreEqual(_apuestaEsperada.Usuario.Id, _apuestaJugador.Usuario.Id); Assert.AreEqual(_apuestaEsperada.Respuesta.Id, _apuestaJugador.Respuesta.Id); }
public HttpResponseMessage ActualizarApuestaJugador(DTOApuestaJugador dto) { try { TraductorApuestaJugador traductor = FabricaTraductor.CrearTraductorApuestaJugador(); Entidad apuesta = traductor.CrearEntidad(dto); Comando comando = FabricaComando.CrearComandoActualizarApuestaJugador(apuesta); comando.Ejecutar(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (ObjetoNullException exc) { log.Error(exc, exc.Mensaje); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc.Mensaje)); } catch (BaseDeDatosException exc) { log.Error(exc, exc.Mensaje); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc.Mensaje)); } catch (ApuestaInvalidaException exc) { log.Error(exc, exc.Mensaje); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc.Mensaje)); } catch (Exception exc) { ExcepcionGeneral exceptionGeneral = new ExcepcionGeneral(exc.InnerException, DateTime.Now); log.Error(exc, exc.Message); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exceptionGeneral.Mensaje)); } }
public HttpResponseMessage ObtenerApuestasJugadorEnCurso(DTOUsuarioId dto) { try { TraductorUsuarioId traductor = FabricaTraductor.CrearTraductorUsuarioId(); Entidad usuario = traductor.CrearEntidad(dto); Comando comando = FabricaComando.CrearComandoObtenerApuestasJugadorEnCurso(usuario); comando.Ejecutar(); TraductorApuestaJugador traductorApuesta = FabricaTraductor.CrearTraductorApuestaJugador(); List <DTOApuestaJugador> Listadtos = traductorApuesta.CrearListaDto(comando.GetEntidades()); return(Request.CreateResponse(HttpStatusCode.OK, Listadtos)); } catch (ObjetoNullException exc) { log.Error(exc, exc.Mensaje); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc.Mensaje)); } catch (BaseDeDatosException exc) { log.Error(exc, exc.Mensaje); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc.Mensaje)); } catch (Exception exc) { ExcepcionGeneral exceptionGeneral = new ExcepcionGeneral(exc.InnerException, DateTime.Now); log.Error(exc, exc.Message); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exceptionGeneral.Mensaje)); } }
public void TraductorDTOApuestaJugadorExceptionTest() { _traductorApuestaJugador = FabricaTraductor.CrearTraductorApuestaJugador(); Assert.Throws <ObjetoNullException>(() => _traductorApuestaJugador.CrearEntidad(null)); }