Ejemplo n.º 1
0
        public HttpResponseMessage ActualizarApuestaCantidad(DTOApuestaCantidad dto)
        {
            try
            {
                TraductorApuestaCantidad traductor = FabricaTraductor.CrearTraductorApuestaCantidad();

                Entidad apuesta = traductor.CrearEntidad(dto);

                Comando comando = FabricaComando.CrearComandoActualizarApuestaCantidad(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 void TraducirApuestaCantidadTest()
        {
            ApuestaCantidad _apuestaEsperada = FabricaEntidades.CrearApuestaCantidad();

            _apuestaEsperada.Respuesta = 1;
            _apuestaEsperada.Logro     = _logroCantidad;
            _apuestaEsperada.Usuario   = _apostador;


            _dtoApuestaCantidad = FabricaDTO.CrearDtoApuestaCantidad();

            _dtoApuestaCantidad.IdLogro        = 1;
            _dtoApuestaCantidad.IdUsuario      = 1;
            _dtoApuestaCantidad.ApuestaUsuario = 1;


            _traductorApuestaCantidad = FabricaTraductor.CrearTraductorApuestaCantidad();

            _apuestaCantidad = _traductorApuestaCantidad.CrearEntidad(_dtoApuestaCantidad) as ApuestaCantidad;

            Assert.AreEqual(_apuestaEsperada.Logro.Id, _apuestaCantidad.Logro.Id);
            Assert.AreEqual(_apuestaEsperada.Usuario.Id, _apuestaCantidad.Usuario.Id);
            Assert.AreEqual(_apuestaEsperada.Respuesta, _apuestaCantidad.Respuesta);
        }
        public void TraductorDTOApuestaCantidadExceptionTest()
        {
            _traductorApuestaCantidad = FabricaTraductor.CrearTraductorApuestaCantidad();

            Assert.Throws <ObjetoNullException>(() => _traductorApuestaCantidad.CrearEntidad(null));
        }