コード例 #1
0
        public void UpdatePersonExist()
        {
            var options = new DbContextOptionsBuilder <EjContext>()
                          .UseInMemoryDatabase(databaseName: "EjDataBase")
                          .Options;

            int    id     = 1;
            Person person = new Person()
            {
                Id      = id,
                Name    = "Nicolas",
                Surname = "Fierro",
                Phone   = "+598274563",
                Email   = "*****@*****.**"
            };

            using (var context = new EjContext(options))
            {
                context.Set <Person>().Add(person);
                context.SaveChanges();
                var manager = new PersonManagerDA(context);
                person.Name = "Braulio";
                manager.Update(person);
                manager.Save();
                Assert.AreEqual(manager.Get(id).Name, "Braulio");
                context.Set <Person>().Remove(person);
                context.SaveChanges();
            }
        }
コード例 #2
0
        public void GetAll()
        {
            var options = new DbContextOptionsBuilder <EjContext>()
                          .UseInMemoryDatabase(databaseName: "EjDataBase")
                          .Options;

            int    id     = 1;
            Person person = new Person()
            {
                Id      = id,
                Name    = "Nicolas",
                Surname = "Fierro",
                Phone   = "+598274563",
                Email   = "*****@*****.**"
            };

            using (var context = new EjContext(options))
            {
                context.Set <Person>().Add(person);
                context.SaveChanges();
                var           manager = new PersonManagerDA(context);
                List <Person> list    = manager.GetAll().ToList();
                Assert.AreEqual(list.Count, 1);
                context.Set <Person>().Remove(person);
                context.SaveChanges();
            }
        }