2009-12-26 9 views
1

Je veux une configuration de test unitaire simple. Ma compréhension est que la config sqlite fluide par défaut à Castle, et j'ai une référence définie à NHibernate.ByteCode.Castle.dll, mais je reçois une erreur disant qu'il n'y a pas de jeu de paramètres ProxyFactory.FluentNibibate SQLite config par défaut ProxyFactoryFactory

Qu'est-ce qui me manque?

Cheers,
Berryl

=== === CODE

public abstract class InMemoryDatabase : IDisposable 
{ 
    private static Configuration _cfg; 
    private static ISessionFactory _sessionFactory; 

    protected InMemoryDatabase() 
    { 
     _sessionFactory = _createSessionFactory(); 
     Session = _sessionFactory.OpenSession(); 
     _buildSchema(Session); 
    } 

    protected ISession Session { get; set; } 

    #region IDisposable Members 

    public void Dispose() { Session.Dispose(); } 

    #endregion 

    private static ISessionFactory _createSessionFactory() 
    { 
     return Fluently.Configure() 
      .Database(SQLiteConfiguration.Standard.InMemory().ShowSql()) 
      .Mappings(M => 
       M.FluentMappings.AddFromAssemblyOf<User>()) 
      .ExposeConfiguration(Cfg => _cfg = Cfg) 
      .BuildSessionFactory(); 
    } 

    private static void _buildSchema(ISession Session) 
    { 
     var export = new SchemaExport(_cfg); 
     export.Execute(true, true, false, Session.Connection, null); 
    } 
} 

==== ==== l'exception

TestCase 'SmackNhibTestLab.FluentMapping.Tests.UserClassMapTests.PersistenceSpec_ok' 
failed: TestFixtureSetUp failed in UserClassMapTests 
TestFixture failed: FluentNHibernate.Cfg.FluentConfigurationException : 
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. 


----> NHibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException : The ProxyFactoryFactory was not configured. 
Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers. 
Example: 
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property> 
Example: 
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property> 
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() 

0 passed, 1 failed, 0 skipped, took 2.55 seconds (NUnit 2.5.2). 

Répondre

3

Vous pouvez définir la propriété vous assez facilement - voir ci-dessous le code pour voir un bon moyen de voir un bon moyen de le faire. Je m'attendais toujours à ce que cette ligne de code ait été cuite dans la configuration par défaut de SQLite?

private static ISessionFactory _createSessionFactory() { 
    var sqLiteConfiguration = Standard.InMemory().ShowSql(); 
    sqLiteConfiguration.ProxyFactoryFactory(typeof(ProxyFactoryFactory).AssemblyQualifiedName); <== ** OK now 

    return Fluently.Configure() 
      .Database(sqLiteConfiguration) 
      .Mappings(M => 
       M.FluentMappings.AddFromAssemblyOf<User>()) 
      .ExposeConfiguration(Cfg => _cfg = Cfg) 
      .BuildSessionFactory(); 
    } 

Cheers, Berryl

Questions connexes