예제 #1
0
        public void TestErrorLetra()
        {
            var target = new Nie();

            target.NumeroDocumento = "X0223150J";
            var result = target.NumeroDocumento;
        }
예제 #2
0
        public void TestErrorLongitud()
        {
            var target = new Nie();

            target.NumeroDocumento = "22222223453534";
            var result = target.NumeroDocumento;
        }
예제 #3
0
        public void TestComprobarLetraNie()
        {
            var target = new Nie();

            target.NumeroDocumento = "X0223150G";
            var result = target.NumeroDocumento;

            Assert.AreEqual("X0223150G", result);
        }
예제 #4
0
 public void NieKos(string value)
 {
     Nie.Create(value).IsValid().Should().BeFalse();
 }
예제 #5
0
 public void NieOks(string value)
 {
     Nie.Create(value).IsValid().Should().BeTrue();
 }
예제 #6
0
 /// <summary>  </summary>
 /// <returns></returns>
 public bool IsValid()
 {
     return(Dni.Create(Value).IsValid() || Nie.Create(Value).IsValid());
 }
예제 #7
0
 public void TestNie()
 {
     var target = new Nie {
         Pais = "Nigeria"
     };
 }
예제 #8
0
        public void TestContext()
        {
            var target = new GpContext();
            {
                try
                {
                    // Your code...
                    // Could also be before try if you know the exception occurs in SaveChanges


                    /* var persona = new Persona();
                     * persona.FechaNacimiento = new DateTime();
                     */
                    var persona = new Persona {
                        FechaNacimiento = new DateTime(2000, 09, 01)
                    };
                    target.Personas.Add(persona);
                    target.SaveChanges();

                    var policia = new Policia {
                        NumeroPlaca = 5
                    };
                    target.Policias.Add(policia);
                    target.SaveChanges();

                    var detenido = new Detenido {
                        FechaDetencion = new DateTime(2000, 02, 01)
                    };
                    target.Detenidos.Add(detenido);
                    target.SaveChanges();

                    var usuario = new Usuario();
                    target.Usuarios.Add(usuario);
                    target.SaveChanges();

                    var dni = new Dni()
                    {
                        NumeroDocumento = "56904819"
                    };
                    target.Dnis.Add(dni);
                    target.SaveChanges();

                    var nie = new Nie()
                    {
                        NumeroDocumento = "Z5164919K"
                    };
                    target.Nies.Add(nie);
                    target.SaveChanges();

                    var pasaporte = new Pasaporte()
                    {
                        NumeroDocumento = "C35890664"
                    };
                    target.Pasaportes.Add(pasaporte);
                    target.SaveChanges();

                    var policias  = target.Policias.Count();
                    var policias2 = target.Personas.OfType <Policia>().Count();
                }

                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine(
                            "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                            eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }