public void Fetched_entitys_relation_should_handle_PropertyChanged()
        {
            var person = new Person
            {
                FirstName = "First name",
                LastName = "Last name",
                Company = new Company { Name = "Company name" }
            };

            using (var transaction = Session.BeginTransaction())
            {
                Session.SaveOrUpdate(person.Company);
                Session.SaveOrUpdate(person);

                transaction.Commit();
            }

            Session.Clear();

            var personFetched = Session.Get<Person>(person.Id);
            Assert.That(personFetched, Is.Not.SameAs(person));

            Assert.That(!NHibernateUtil.IsInitialized(personFetched.Company));
            Check_entity_handles_PropertyChanged(personFetched.Company);
        }
        public void Created_entity_should_handle_PropertyChanged()
        {
            var person = new Person
            {
                FirstName = "First name",
                LastName = "Last name",
                Company = new Company { Name = "Company name" }
            };

            Check_entity_handles_PropertyChanged(person);
        }
        private void Check_entity_handles_PropertyChanged(Person person)
        {
            var eventWasCalled = false;
            var propertyName = string.Empty;
            object sender = null;

            person.PropertyChanged += (s, e) => { eventWasCalled = true; sender = s; propertyName = e.PropertyName; };

            person.FirstName = "New first name";

            Assert.That(eventWasCalled);
            Assert.That(propertyName, Is.EqualTo("FirstName"));
            Assert.That(sender, Is.SameAs(person));
        }