Пример #1
0
        public void Session_Delete_Employee(ISession session)
        {
            session.WithRollback(s =>
                {
                    var count = session.GetAll<Employee>().Count();
                    var sergio = session.Insert(new Employee
                    {
                        FirstName = "Sérgio",
                        LastName = "Ferreira"
                    });

                    session.Delete(sergio);

                    Assert.AreEqual(count, session.GetAll<Employee>().Count());
                }
            );
        }
Пример #2
0
        public void Session_Update_Employee(ISession session)
        {
            session.WithRollback(s =>
                {
                    var sergio = session.Insert(new Employee
                    {
                        FirstName = "Sérgio",
                        LastName = "Ferreira"
                    });

                    sergio.FirstName = "Alien";

                    session.Update(sergio);

                    var alien = session.GetById(sergio);

                    Assert.That(alien, Is.Not.Null);
                    Assert.AreEqual("Alien", alien.FirstName);
                }
            );
        }
Пример #3
0
        public void Session_Insert_Employee(ISession session)
        {
            session.WithRollback(s =>
            {
                var count = session.GetAll<Employee>().Count();
                var employee = session
                    .Insert(new Employee
                    {
                        FirstName = "Sérgio",
                        LastName = "Ferreira"
                    });

                Assert.IsNotNull(employee);
                Assert.AreEqual(count + 1, session.GetAll<Employee>().Count());
            });
        }