Example #1
0
        public static DummyPerson CreateDummyPerson()
        {
            var person = new DummyPerson();
            person.BirthDate = RandomBirthDate();
            person.Name = RandomName();
            person.Age = DateTime.Now.Year - person.BirthDate.Year;
            person.IsAdult = person.Age > 18;

            return person;
        }
Example #2
0
        public void TestErrorHandler()
        {
            try
            {
                var person = new DummyPerson()
                {
                    BirthAt = new DateTime(1985, 4, 5),
                    Email = "*****@*****.**",
                    Name = "Some Name"
                };

                var person2 = DummyMapper.ToAnotherPerson(person);
            }
            catch (Exception ex)
            {
                if (!ex.Message.Equals("Se ha producido un error inesperado al mapear el objeto. El error se produjo en la clase DummyMapper, método ToAnotherPerson. Revise la pila de excepciones para mayor información"))
                    throw new Exception("Prueba no superada");
            }
        }
Example #3
0
        public static DummyPerson2 ToAnotherPerson(DummyPerson person)
        {
            CheckParameter(person);

            try
            {
                var a = 1;
                var b = 0;
                var c = a / b;

                return(new DummyPerson2()
                {
                    BirthAt2 = person.BirthAt,
                    Email2 = person.Email,
                    Name2 = person.Name
                });
            }
            catch (Exception ex)
            {
                ErrorHandler(ex);
                return(null);
            }
        }
Example #4
0
        public static DummyPerson2 ToAnotherPerson(DummyPerson person)
        {
            CheckParameter(person);

            try
            {
                var a = 1;
                var b = 0;
                var c = a/b;

                return new DummyPerson2()
                {
                    BirthAt2 = person.BirthAt,
                    Email2 = person.Email,
                    Name2 = person.Name
                };
            }
            catch (Exception ex)
            {
                ErrorHandler(ex);
                return null;
            }
        }