public void Derives_valid_filename_from_session_factory_ID_when_not_explicitly_specified() { var configurationPersister = MockRepository.GenerateMock<IConfigurationPersister>(); configurationPersister.Expect(x => x.IsNewConfigurationRequired(null, null)) .IgnoreArguments() .Constraints(Is.Equal("sessionFactory1.dat"), Is.Anything()) .Return(false); var builder = new PersistentConfigurationBuilder(configurationPersister); builder.GetConfiguration(facilityCfg); configurationPersister.VerifyAllExpectations(); }
public void Includes_mapping_assemblies_in_dependent_file_list() { var configurationPersister = MockRepository.GenerateMock<IConfigurationPersister>(); configurationPersister.Expect(x => x.IsNewConfigurationRequired(null, null)) .IgnoreArguments() .Constraints(Is.Anything(), List.ContainsAll(new[] {"Castle.Facilities.NHibernateIntegration.Tests.dll" })) .Return(false); var builder = new PersistentConfigurationBuilder(configurationPersister); builder.GetConfiguration(facilityCfg); configurationPersister.VerifyAllExpectations(); }
public void Derives_valid_filename_from_session_factory_ID_when_not_explicitly_specified() { var configurationPersister = MockRepository.GenerateMock <IConfigurationPersister>(); configurationPersister.Expect(x => x.IsNewConfigurationRequired(null, null)) .IgnoreArguments() .Constraints(Is.Equal("sessionFactory1.dat"), Is.Anything()) .Return(false); var builder = new PersistentConfigurationBuilder(configurationPersister); builder.GetConfiguration(facilityCfg); configurationPersister.VerifyAllExpectations(); }
public void Includes_mapping_assemblies_in_dependent_file_list() { var configurationPersister = MockRepository.GenerateMock <IConfigurationPersister>(); configurationPersister.Expect(x => x.IsNewConfigurationRequired(null, null)) .IgnoreArguments() .Constraints(Is.Anything(), List.ContainsAll(new[] { "Castle.Facilities.NHibernateIntegration.Tests.dll" })) .Return(false); var builder = new PersistentConfigurationBuilder(configurationPersister); builder.GetConfiguration(facilityCfg); configurationPersister.VerifyAllExpectations(); }
static NHibernateHelper() { try { // Configuration cfg = new Configuration(); // cfg.Configure(); // cfg.AddAssembly(typeof(Klub).Assembly); Configuration cfg = new PersistentConfigurationBuilder().GetConfiguration(); SessionFactory = cfg.BuildSessionFactory(); } catch (Exception ex) { // TODO: Use your own logging mechanism rather than Console.Error Console.Error.WriteLine(ex); throw new Exception("NHibernate initialization failed", ex); } }
private ISessionFactory createSessionFactory() { try { Configuration cfg = new PersistentConfigurationBuilder().GetConfiguration(); // Configuration cfg = new Configuration(); // cfg.Configure(); // cfg.AddAssembly(typeof(Klub).Assembly); /*string configurationPath = HttpContext.Current.Server.MapPath(@"~\Models\Nhibernate\hibernate.cfg.xml"); * cfg.Configure(configurationPath); * string employeeConfigurationFile = HttpContext.Current.Server.MapPath(@"~\Models\Nhibernate\Gimnasticar.hbm.xml"); * cfg.AddFile(employeeConfigurationFile);*/ return(cfg.BuildSessionFactory()); } catch (Exception ex) { // TODO: Use your own logging mechanism rather than Console.Error Console.Error.WriteLine(ex); throw new Exception("NHibernate initialization failed", ex); } }
private ISessionFactory createSessionFactory() { try { Configuration cfg = new PersistentConfigurationBuilder().GetConfiguration(); // Configuration cfg = new Configuration(); // cfg.Configure(); // cfg.AddAssembly(typeof(Klub).Assembly); /*string configurationPath = HttpContext.Current.Server.MapPath(@"~\Models\Nhibernate\hibernate.cfg.xml"); cfg.Configure(configurationPath); string employeeConfigurationFile = HttpContext.Current.Server.MapPath(@"~\Models\Nhibernate\Gimnasticar.hbm.xml"); cfg.AddFile(employeeConfigurationFile);*/ return cfg.BuildSessionFactory(); } catch (Exception ex) { // TODO: Use your own logging mechanism rather than Console.Error Console.Error.WriteLine(ex); throw new Exception("NHibernate initialization failed", ex); } }