Inheritance: ActiveRecordBase
		public void ManyToMany()
		{
			ActiveRecordStarter.Initialize( GetConfigSource(), 
				typeof(Company), typeof(Client), typeof(Firm), typeof(Person),
				typeof(Blog), typeof(Post));
			Recreate();

			Company.DeleteAll();
			Client.DeleteAll();
			Firm.DeleteAll();
			Person.DeleteAll();

			Firm firm = new Firm("keldor");
			Client client = new Client("castle", firm);
			Company company = new Company("vs");

			using(new SessionScope())
			{
				firm.Save();
				client.Save();
				company.Save();

				Person person = new Person();
				person.Name = "hammett";

				person.Companies.Add( firm );
				person.Companies.Add( client );
				person.Companies.Add( company );
				person.Save();
			}

			company = Company.Find( company.Id );
			Assert.AreEqual(1, company.People.Count );
		}
        public void ComponentAttribute()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(),
                                           typeof(Company),
                                           typeof(Client),
                                           typeof(Firm),
                                           typeof(Person),
                                           typeof(Post),
                                           typeof(Blog));
            Recreate();

            Company.DeleteAll();

            Company company = new Company("Castle Corp.");
            company.Address = new PostalAddress(
                "Embau St., 102", "Sao Paulo", "SP", "040390-060");
            company.Save();

            Company[] companies = Company.FindAll();
            Assert.IsNotNull(companies);
            Assert.AreEqual(1, companies.Length);

            Company corp = companies[0];
            Assert.IsNotNull(corp.Address);
            Assert.AreEqual(corp.Address.Address, company.Address.Address);
            Assert.AreEqual(corp.Address.City, company.Address.City);
            Assert.AreEqual(corp.Address.State, company.Address.State);
            Assert.AreEqual(corp.Address.ZipCode, company.Address.ZipCode);
        }
        public void InvalidSessionCache()
        {
            ActiveRecordStarter.Initialize( GetConfigSource(),
                typeof(Company), typeof(Client), typeof(Firm), typeof(Person) );
            Recreate();

            Company.DeleteAll();
            Client.DeleteAll();
            Firm.DeleteAll();
            Person.DeleteAll();

            Firm firm = new Firm("keldor");
            Client client = new Client("castle", firm);
            Company company = new Company("vs");

            using(new SessionScope())
            {
                firm.Save();
                client.Save();
                company.Save();
            }

            using(new SessionScope())
            {
                try
                {
                    Client c = Client.Find( firm.Id );

                    Assert.Fail("Exception was expected");
                }
                catch(Exception)
                {
                    // Phew!!
                }

                Firm firm2 = Firm.Find( firm.Id );

                Assert.IsNotNull(firm2);
            }
        }
        public void ExplicitFlushInsideSecondTransactionProblem()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(),
                typeof(Company),
                typeof(Person),
                typeof(Blog),
                typeof(Post));
            Recreate();

            Company comp1 = new Company("comp1");
            Company comp2 = new Company("comp2");
            using(new SessionScope())
            {
                comp1.Create();
                comp2.Create();
            }

            using(new SessionScope(FlushAction.Never))
            {
                using(TransactionScope tx = new TransactionScope(OnDispose.Rollback))
                {
                    Company comp2a = Company.Find(comp2.Id);
                    comp2a.Name = "changed";
                    tx.VoteCommit();
                }

                using(new TransactionScope(OnDispose.Rollback))
                {
                    Company[] changedCompanies = ActiveRecordMediator<Company>.FindAllByProperty("Name", "changed");
                    Assert.AreEqual(1, changedCompanies.Length);
                    Company e2a = changedCompanies[0];
                    e2a.Delete();

                    SessionScope.Current.Flush();

                    Assert.AreEqual(0, ActiveRecordMediator<Company>.FindAllByProperty("Name", "changed").Length);
                }
            }
        }
		public void ReportedProblemOnForum()
		{
			ActiveRecordStarter.Initialize(GetConfigSource(), 
				typeof(Company), 
				typeof(Person),
				typeof(Blog),
				typeof(Post));
			Recreate();

			using(new TransactionScope())
			{
				Company comp1 = new Company("comp1");
				comp1.Create();

				Company comp2 = new Company("comp2");
				comp2.Create();
			}
		}