예제 #1
0
 public IHttpActionResult Add(BodegaDto bodega)
 {
     try
     {
         return(Ok(_service.AddBodega(bodega)));;
     }
     catch (DbEntityValidationException efEx)
     {
         _logs.LogDbEntityValidationException(efEx);
     }
     catch (Exception ex)
     {
         _logs.LogException(ex);
     }
     return(Content(HttpStatusCode.NotFound, StringEnum.GetStringValue(MensajeError.NoRecuperado)));
 }
예제 #2
0
        AddBodegaReturnCorrectBodega()
        {
            //Arrange
            Bodega bodega = new Bodega()
            {
                NotificadoCaducidad = It.IsAny <bool>(),
                Unidades            = It.IsAny <int>(),
                Botella             = new Botella()
                {
                    Id          = 4,
                    Descripcion = "Botella 4",
                    Añada       = It.IsAny <int>(),
                    Caducidad   = It.IsAny <DateTime>(),
                    Disponible  = true,
                    IdVino      = It.IsAny <int>(),
                    Vino        = new Vino()
                    {
                        Id           = It.IsAny <int>(),
                        Nombre       = It.IsAny <string>(),
                        Variedad     = It.IsAny <string>(),
                        Crianza      = It.IsAny <string>(),
                        Denominacion = It.IsAny <string>(),
                        Color        = It.IsAny <string>(),
                        Baja         = false,
                        Capacidad    = It.IsAny <decimal>()
                    }
                }
            };

            BodegaDto bodegadto = new BodegaDto()
            {
                NotificadoCaducidad = It.IsAny <bool>(),
                Unidades            = 25,
                Botella             = new BotellaDto()
                {
                    Id          = 4,
                    Descripcion = "Botella 4",
                    Añada       = It.IsAny <int>(),
                    Caducidad   = It.IsAny <DateTime>(),
                    Disponible  = true,
                    IdVino      = It.IsAny <int>(),
                    Vino        = new VinoDto()
                    {
                        Id           = It.IsAny <int>(),
                        Nombre       = It.IsAny <string>(),
                        Variedad     = It.IsAny <string>(),
                        Crianza      = It.IsAny <string>(),
                        Denominacion = It.IsAny <string>(),
                        Color        = It.IsAny <string>(),
                        Baja         = false,
                        Capacidad    = It.IsAny <decimal>()
                    }
                }
            };

            _bodegaRepository.Setup(x => x.Create(It.IsAny <Bodega>())).Returns(bodega);

            //Act
            var result = _service.AddBodega(bodegadto);

            //Assert
            Assert.AreEqual(result.Unidades, 25);
        }