public void Seguro_CriarNovo()
        {
            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());

            mock.Object.AddRange(data);
            var mockContext = new Mock <DBContext>();

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

            var service = new SeguroService(mockContext.Object);

            service.Insert(new SeguroModel()
            {
                IDTipo = 4, CPFCNPJ = "123123123-12", Placa = "AYB5757"
            });

            mock.Verify(m => m.Add(It.IsAny <Seguro>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
Esempio n. 2
0
        public JsonResult Salvar(SeguroModel model)
        {
            Result result = new Result();

            try
            {
                var service = new SeguroService(new Business.DBContext());
                if (model.ID == 0)
                {
                    service.Insert(model);
                }
                else
                {
                    service.Update(model);
                }

                result.setSuccess();
            }
            catch (Exception ex)
            {
                result.setError(ex.Message);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public void testInserts()
        {
            Seguro Dados = new Seguro()
            {
                Cliente = new Cliente {
                    Nome = "Thiago", CPF = "11111111111", Idade = 27
                },
                Veiculo = new Veiculo {
                    Marca = "Honda", Modelo = "Fit", Valor = 70000
                }
            };

            IClienteService _clienteService = new ClienteService(new ClienteRepository());
            IVeiculoService _veiculoService = new VeiculoService(new VeiculoRepository());
            ISeguroService  _seguroService  = new SeguroService(new SeguroRepository());

            Dados.Cliente = _clienteService.Adicionar(Dados.Cliente);

            Dados.Veiculo.Id_Cliente = Dados.Cliente.Id;
            Dados.Veiculo            = _veiculoService.Adicionar(Dados.Veiculo);

            var seguro = _seguroService.Adicionar(Dados);

            Assert.AreEqual(true, seguro != null);
        }
Esempio n. 4
0
        public SeguroController()
        {
            Banco     banco     = new Banco();
            SeguroDAL seguroDAL = new SeguroDAL(banco);

            _seguroService = new SeguroService(seguroDAL);
        }
        private SeguroController InstanciarCamadas2()
        {
            Banco         banco         = new Banco();
            SeguroDAL     seguroDAL     = new SeguroDAL(banco);
            SeguroService seguroService = new SeguroService(seguroDAL);

            return(new SeguroController(seguroService));
        }
Esempio n. 6
0
 public SeguroTest()
 {
     _context.Carros.AddRange(CriarEntidade.CriarBaseCarros());
     _context.Segurados.AddRange(CriarEntidade.CriarBaseSegurados());
     _context.Seguros.AddRange(CriarEntidade.CriarBaseSeguros());
     _context.SaveChanges();
     _mockSeguroRepository   = new SeguroRepository(_context);
     _seguroServices         = new SeguroService(_mockSeguroRepository);
     _mockCarroRepository    = new CarroRepository(_context);
     _carroServices          = new CarroService(_mockCarroRepository);
     _mockSeguradoRepository = new SeguradoRepository(_context);
     _seguradoServices       = new SeguradoService(_mockSeguradoRepository);
 }
Esempio n. 7
0
 public ConsultasController(SeguroService seguroService, ApoliceService apoliceService, AutomovelService automovelService, AbastecimentoService abastecimentoService, ManutencaoService manutencaoService, MotoristaService motoristaService, MultaService multaService, OficinaService oficinaService, PostoService postoService, ViagemService viagemService, TodosMotoristaService todosMotoristaService, TodosAutomovelService todosAutomovelService)
 {
     _seguroService         = seguroService;
     _apoliceService        = apoliceService;
     _automovelService      = automovelService;
     _abastecimentoService  = abastecimentoService;
     _manutencaoService     = manutencaoService;
     _motoristaService      = motoristaService;
     _multaService          = multaService;
     _oficinaService        = oficinaService;
     _postoService          = postoService;
     _viagemService         = viagemService;
     _todosMotorstaService  = todosMotoristaService;
     _todosAutomovelService = todosAutomovelService;
 }
Esempio n. 8
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);
        }
Esempio n. 10
0
        public JsonResult ListarGrid(Grid.Request request, SeguroModel model)
        {
            Grid.Result <object> gridModel = new Grid.Result <object>();

            try
            {
                var service = new SeguroService(new Business.DBContext());
                var list    = service.GetAll(model);

                gridModel.total = list.Count();
                gridModel.list  = list.ToList <object>();
            }
            catch (Exception ex)
            {
                gridModel.error     = true;
                gridModel.errorCode = 999;
                gridModel.message   = ex.Message;
            }

            return(Json(gridModel, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
        public void Seguro_GetAll()
        {
            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());

            mock.Object.AddRange(data);
            var mockContext = new Mock <DBContext>();

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

            var service = new SeguroService(mockContext.Object);
            var result  = service.GetAll(new SeguroModel()
            {
                IDTipo = 1
            });

            Assert.AreEqual(_dataSource.Where(d => d.IDTipo == 1).Count(), result.Count());
        }
Esempio n. 12
0
 public SeguroController(SeguroService seguroService)
 {
     _seguroService = seguroService;
 }
Esempio n. 13
0
 public SeguroController()
 {
     seguroService         = new SeguroService();
     veiculoService        = new VeiculoService();
     pessoaJuridicaService = new PessoaJuridicaService();
 }
 public SinistroController()
 {
     sinistroService = new SinistroService();
     seguroService   = new SeguroService();
 }