Exemplo n.º 1
0
        public void GetByIdTestOk()
        {
            typeReqRepository.Setup(u => u.Exists(It.IsAny <Expression <Func <TypeReqEntity, bool> > >())).Returns(true);
            typeReqRepository.Setup(r => r.FirstOrDefault(It.IsAny <Expression <Func <TypeReqEntity, bool> > >())).Returns(testTypeReqEntity);

            var result = typeReqLogic.GetById(testTypeReqEntity.Id);

            typeReqRepository.VerifyAll();
            Assert.IsNotNull(result);
            Assert.AreEqual(testTypeReqEntity.Name, result.Name);
        }
Exemplo n.º 2
0
        public ActionResult Get(int id)
        {
            TypeReqEntity typeReq;

            try
            {
                typeReq = typeReqLogic.GetById(id);
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            var requestOut = mapper.Map <TypeReqEntity, TypeReqModelOut>(typeReq);

            return(this.Ok(requestOut));
        }