public void PrepareSessionFactory()
        {
            Configuration = new Configuration();
            Configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
                .DataBaseIntegration(db =>
                                         {
                                             db.ConnectionStringName = "db";
                                             db.Dialect<MsSql2008Dialect>();
                                         });
            Configuration.SetProperty("show_sql", "true");
            Configuration.SetDefaultAssembly("NHibernateDeepDive");
            Configuration.SetDefaultNamespace("NHibernate_Deep_Dive.Entities");
            Configuration.AddXmlFile("ClearDatabaseScript.hbm.xml");
            foreach (var mappingFile in Directory.GetFiles(MappingsDirectory))
            {
                Configuration.AddXmlFile(mappingFile);
            }
            AdjustConfiguration(Configuration);
            Configuration.SessionFactory().GenerateStatistics();

            SessionFactory = Configuration.BuildSessionFactory();

            //new SchemaExport(Configuration).Drop(false, true);
            new SchemaExport(Configuration).Execute(false, true, false);

            BeforeTestRun();
            PopulateDatabase();

            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
        }
		public void InvalidXmlInHbmFile()
		{
			string filename = "invalid.hbm.xml";
			// it's missing the class name - won't validate
			string hbm = @"<?xml version='1.0' encoding='utf-8' ?> 
							<hibernate-mapping xmlns='urn:nhibernate-mapping-2.0'>
								<class table='a'></class>
							</hibernate-mapping>";
			XmlDocument hbmDoc = new XmlDocument();
			hbmDoc.LoadXml( hbm );
			hbmDoc.Save( filename );

			Configuration cfg = new Configuration();
			try 
			{
				cfg.Configure();
				cfg.AddXmlFile( "invalid.hbm.xml" );
			}
			catch( HibernateException )
			{
				// just absorb it - not what we are testing
			}
			finally 
			{
				// clean up the bad file - if the AddXmlFile method cleans up after
				// itself we should be able to do this without problem.  If it does
				// property release the resource then this won't be able to access
				// the file to delete.
				System.IO.File.Delete( filename );
			}
		}
Beispiel #3
0
    static NHSessionManager()
    {
        try
        {
            Configuration cfg = new Configuration();
            string configFile = Helper.IsDevelopment()
                ? @"hibernate.debug.cfg.xml"
                : @"hibernate.cfg.xml";
            string mappingPath = PathFunctions.GetMappingPath();
            cfg.Configure(Path.Combine(mappingPath, configFile));
            foreach (string file in Directory.GetFiles(mappingPath, "*.hbm.xml"))
                cfg.AddXmlFile(file);
            factory = cfg.BuildSessionFactory();
        }
        catch
        {

        }
    }
Beispiel #4
0
 static NHSessionManager()
 {
     try
     {
         Configuration cfg = new Configuration();
         string configFile = @"hibernate.cfg.xml";
         string mappingPath = PathFunctions.GetMappingPath();
         cfg.Configure(Path.Combine(mappingPath, configFile));
         foreach (string file in Directory.GetFiles(mappingPath, "*.hbm.xml"))
             cfg.AddXmlFile(file);
         factory = cfg.BuildSessionFactory();
     }
     catch(Exception ex)
     {
         Log.Add(ex.ToString());
     }
 }
        public void TestSetup()
        {
            Configuration cfg = new Configuration();

            cfg.AddXmlFile(@"C:\Documents and Settings\James Avery\My Documents\My Projects\NHibernate.Nullables2\nhibtest\FooBar.hbm.xml");

            factory = cfg.BuildSessionFactory();
        }