示例#1
0
 public JsonResult Excluir(int id)
 {
     try
     {
         var msg = CreateMessageJson(new Mensagem(Descricoes.MSG003, Tipo.Sucesso));
         seguroService.Delete(id);
         return(Json(msg));
     }
     catch (Exception ex)
     {
         return(Json(CreateMessageJson(ex)));
     }
 }
示例#2
0
        public JsonResult Excluir(SeguroModel model)
        {
            Result result = new Result();

            try
            {
                var service = new SeguroService(new Business.DBContext());
                service.Delete(model.ID);
            }
            catch (Exception ex)
            {
                result.setError(ex.Message);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public void Seguro_Delete()
        {
            var data = _dataSource.AsQueryable();

            var mock = new Mock <DbSet <Seguro> >();

            mock.As <IQueryable <Seguro> >().Setup(m => m.Provider).Returns(data.Provider);
            mock.As <IQueryable <Seguro> >().Setup(m => m.Expression).Returns(data.Expression);
            mock.As <IQueryable <Seguro> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mock.As <IQueryable <Seguro> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <DBContext>();

            mockContext.Setup(m => m.Seguro).Returns(mock.Object);

            var service = new SeguroService(mockContext.Object);
            var result  = service.Delete(1);

            Assert.AreEqual(true, result);
        }