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

            Assert.That(person, Is.Not.InstanceOf<INotifyPropertyChanged>());
        }
        public void Fetched_entity_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));

            Check_entity_handles_PropertyChanged(personFetched);
        }
        private void Check_entity_handles_PropertyChanged(Person person)
        {
            Assert.That(person, Is.InstanceOf<INotifyPropertyChanged>());

            var eventWasCalled = false;
            var propertyName = string.Empty;
            object sender = null;

            ((INotifyPropertyChanged)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));
        }