Exemple #1
0
 public static int crearTipoEmpresa(string nombre)
 {
     using (var entities = new SeguroEntities())
     {
         T_EMPRESA tipoEmpresa = new T_EMPRESA();
         tipoEmpresa.NOMBRE = nombre;
         entities.T_EMPRESA.Add(tipoEmpresa);
         entities.SaveChangesAsync();
         return(tipoEmpresa.ID_T_EMPRESA);
     }
 }
Exemple #2
0
 public void obtenerPlanAfiliadoTest()
 {
     using (var entities = new SeguroEntities())
     {
         #region prep
         T_EMPRESA tipoEmpresa = new T_EMPRESA();
         tipoEmpresa.NOMBRE = "Empresa publica";
         entities.T_EMPRESA.Add(tipoEmpresa);
         entities.SaveChangesAsync();
         EMPRESA empresa = new EMPRESA();
         empresa.NOMBRE       = "Fonasa";
         empresa.ID_T_EMPRESA = tipoEmpresa.ID_T_EMPRESA;
         entities.EMPRESA.Add(empresa);
         entities.SaveChangesAsync();
         PLAN plan = new PLAN();
         plan.NOMBRE     = "Plan bacan";
         plan.ID_EMPRESA = empresa.ID_EMPRESA;
         entities.PLAN.Add(plan);
         entities.SaveChangesAsync();
         AFILIADO afiliado = new AFILIADO();
         afiliado.RUT         = 999;
         afiliado.VERIFICADOR = "k";
         afiliado.ID_PLAN     = plan.ID_PLAN;
         AFILIADO sinPlan = new AFILIADO();
         sinPlan.RUT = 123;
         entities.AFILIADO.Add(sinPlan);
         entities.AFILIADO.Add(afiliado);
         entities.SaveChangesAsync();
         #endregion
         //Caso 1: obtiene plan correctamente
         AccionesSeguro accionesSeguro = new AccionesSeguro();
         PLAN           resultado1     = accionesSeguro.obtenerPlanAfiliado(afiliado);
         Assert.IsTrue(resultado1.NOMBRE == plan.NOMBRE);
         //Caso 2: afiliado no tiene plan
         try
         {
             PLAN resultado2 = accionesSeguro.obtenerPlanAfiliado(sinPlan);
             Assert.Fail("No debería tocar esta parte");
         }
         catch (Exception)
         {
         }
     }
 }