Ejemplo n.º 1
0
        public void Delete(int id)
        {
            var person = _dbContext.Set <Person>().Where(p => p.Id.Equals(id))
                         .SingleOrDefault();

            _dbContext.Set <Person>().Remove(person);
            _dbContext.SaveChanges();
        }
Ejemplo n.º 2
0
        public void GetList()
        {
            var at = new Person()
            {
                Id   = 1010,
                Name = "Giorgio Agamben",
                IdentificationDocument = "3019999",
                Gender    = true,
                BirthDate = DateTime.MinValue.AddYears(1942),
                AddressId = 1,
                Address   = new Address()
            };

            _dbContextInMemory.AddRange(at);
            _dbContextInMemory.SaveChanges();

            IPersonRepository personRepository = new PersonRepositoryImpl(_dbContextInMemory);
            var service = new PersonServiceApp(personRepository);

            IList <Person> people = service.Get(null, 10);

            Assert.IsNotNull(people);
            Assert.IsTrue(people.ToList().Count > 0);

            Assert.AreEqual(at.Id, people[0].Id);
            Assert.AreEqual(at.Name, people[0].Name);
            Assert.AreEqual(at.IdentificationDocument, people[0].IdentificationDocument);
            Assert.AreEqual(at.Gender, people[0].Gender);
            Assert.AreEqual(at.BirthDate, people[0].BirthDate);
            Assert.AreEqual(at.AddressId, people[0].AddressId);
        }