public void Devera_Desarquivar_Erro() { var fakeContext = new FakeContext("DesarquivaErro"); _contextoFake.FillWithAll(); var fakeErro = new Erro(); fakeErro.AmbienteId = 1; fakeErro.Arquivado = true; fakeErro.Coletado = "Squad"; fakeErro.Data = DateTime.Today; fakeErro.Descricoes = "haha"; fakeErro.EventoId = 2; fakeErro.Ip = "11234"; fakeErro.NivelId = 2; fakeErro.Titulo = "Teste Squad"; using (var context = new Context(fakeContext.FakeOptions)) { var service = new ErroService(context); var actual = service.Salvar(fakeErro); service.Desarquivar(fakeErro); Assert.False(fakeErro.Arquivado); } }
public void Devera_Add_Novo_Erro() { var fakeContext = new FakeContext("AddErro"); var fakeErro = new Erro(); fakeErro.AmbienteId = 1; fakeErro.Arquivado = false; fakeErro.Coletado = "Squad"; fakeErro.Data = DateTime.Today; fakeErro.Descricoes = "haha"; fakeErro.EventoId = 2; fakeErro.Ip = "11234"; fakeErro.NivelId = 2; fakeErro.Titulo = "Teste Squad"; using (var context = new Context(fakeContext.FakeOptions)) { var service = new ErroService(context); var actual = service.Salvar(fakeErro); Assert.NotEqual(0, actual.Id); Assert.NotEqual(0, actual.AmbienteId); Assert.NotEqual(0, actual.EventoId); Assert.NotEqual(0, actual.NivelId); } }
public ActionResult Excluir(int id) { using (ErroService service = new ErroService()) { service.Excluir(id); return(Json(new { mensagem = "O registro foi incluído com sucesso" })); } }
public ActionResult Buscar(int id) { using (ErroService service = new ErroService()) { ErroDTO retorno = service.Buscar(id).ToDTO <Erro, ErroDTO>(); return(Json(new { resultado = retorno })); } }
public ActionResult Index() { using (ErroService service = new ErroService()) { List <ErroDTO> lstRetorno = service.ListarDTO(); return(Json(new { resultado = lstRetorno, qtdRegistro = lstRetorno.Count() })); } }
public ErroServiceTest() { _contextoFake = new FakeContext("ErroTest"); _contextoFake.FillWithAll(); _contexto = new Context(_contextoFake.FakeOptions); _erroService = new ErroService(_contexto); }
public ActionResult Incluir(ErroDTO registro) { using (ErroService service = new ErroService()) { var model = registro.ToModel <Erro, ErroDTO>(service.Conn); service.Incluir(model); return(Json(new { mensagem = "O registro foi incluído com sucesso" })); } }
public ActionResult Atualizar(ErroDTO registro) { using (ErroService service = new ErroService()) { var model = registro.ToModel <Erro, ErroDTO>(service.Conn); if (model == null || !model.Id.HasValue) { throw new Exception("O registro para alteração informado não foi encontrado"); } service.Atualizar(model); return(Json(new { mensagem = "O registro foi alterado com sucesso" })); } }