Exemplo n.º 1
0
        public void Update()
        {
            var personId = 0;

            using (var context = new TestDbContext()) {
                var person = context.People.Add(new Person {
                    FirstName = "Allan",
                    LastName = "Ritchie",
                    Family = new Family {
                        Name = "Family1",
                        Date = DateTime.Now
                    }
                });
                context.SaveChanges();

                Assert.AreNotEqual(0, person.Version, "Version was not set");
                personId = person.ID;
            }
            using (var context = new TestDbContext()) {
                var person = context.People.Find(personId);
                person.LastName = "Blah";
                context.SaveChanges();

                Assert.AreEqual(2, person.Version, "Version was not updated");
            }
        }
Exemplo n.º 2
0
        public void Update()
        {
            var personId = 0;
            using (var context = new TestDbContext()) {
                var person = context.People.Add(new Person {
                    FirstName = "Allan",
                    LastName = "Ritchie",
                    Family = new Family {
                        Name = "Family1",
                        Date = DateTime.Now
                    }
                });
                context.SaveChanges();

                Assert.AreNotEqual(DateTimeOffset.MinValue, person.DateCreated, "DateCreated was not set");
                personId = person.ID;
            }
            using (var context = new TestDbContext()) {
                var person = context.People.Find(personId);
                person.LastName = "Blah";
                context.SaveChanges();

                Assert.AreNotEqual(DateTimeOffset.MinValue, person.DateUpdated, "DateCreated was not saved");
            }
        }
Exemplo n.º 3
0
 public void Insert_NoVersion()
 {
     using (var context = new TestDbContext()) {
         context.Families.Add(new Family {
             Name = "Insert_NoTimestampProperty",
             Date = DateTime.Now
         });
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public void Insert()
        {
            var personId = 0;
            using (var context = new TestDbContext()) {
                var person = context.People.Add(new Person {
                    FirstName = "Allan",
                    LastName = "Ritchie",
                    Family = new Family {
                        Name = "Family1",
                        Date = DateTime.Now
                    }
                });
                context.SaveChanges();

                Assert.AreEqual(1, person.Version, "Version was not set");
                personId = person.ID;
            }
            using (var context = new TestDbContext()) {
                // re-read to make sure it saved
                var person = context.People.Find(personId);
                Assert.AreEqual(1, person.Version, "Version was not saved");
            }
        }