Exemplo n.º 1
0
        AddBotellaReturnCorrectBotella()
        {
            //Arrange
            Botella botella = new Botella()
            {
                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>()
                }
            };

            BotellaDto botelladto = new BotellaDto()
            {
                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 <Botella>())).Returns(botella);

            //Act
            var result = _service.AddBotella(botelladto);

            //Assert
            Assert.AreEqual(result.Descripcion, "Botella 4");
        }
Exemplo n.º 2
0
 public IHttpActionResult Add(BotellaDto botella)
 {
     try
     {
         return(Ok(_service.AddBotella(botella)));;
     }
     catch (DbEntityValidationException efEx)
     {
         _logs.LogDbEntityValidationException(efEx);
     }
     catch (Exception ex)
     {
         _logs.LogException(ex);
     }
     return(Content(HttpStatusCode.NotFound, StringEnum.GetStringValue(MensajeError.NoRecuperado)));
 }