c# - Can't get ActiveRecordSectionHandler to work properly -
i have following config set in test project:
<configuration> <configsections> <section name="activerecord" type="castle.activerecord.framework.config.activerecordsectionhandler, castle.activerecord" /> ... </configsections> ... <activerecord> <config> <add key="connection.provider" value="(mynamespace).tests.helpers.testingconnectionprovider, (mynamespace).tests" /> <add key="dialect" value="nhibernate.dialect.nhibernate.dialect.sqlitedialect" /> <add key="connection.driver_class" value="nhibernate.driver.sqlitedriver" /> <add key="connection.connection_string" value="data source=:memory:;version=3;new=true;" /> <add key="show_sql" value="true" /> <add key="query.substitutions" value="true=1;false=0" /> <add key="proxyfactory.factory_class" value="nhibernate.bytecode.castle.proxyfactoryfactory, nhibernate.bytecode.castle"/> </config> </activerecord> ... </configuration>
i have added nhibernate prefix keys, documentation has suggested. connection provider looks like:
public class testingconnectionprovider : driverconnectionprovider { public static idbconnection connection { get; private set; } public override idbconnection getconnection() { return connection ?? (connection = base.getconnection()); } }
when try run test:
[testclass] public class persistencetests { [testmethod] public void canbuildschemainmemory() { if (file.exists("sqlcreate.sql")) file.delete("sqlcreate.sql"); activerecordstarter.initialize(typeof(ipermissionsmanager).assembly, new activerecordsectionhandler()); activerecordstarter.generatecreationscripts("createnew.sql"); assert.istrue(file.exists("sqlcreate.sql")); } }
... failure indicates not set up. however, if change activerecordsectionhandler()
out for:
inplaceconfigurationsource.build(databasetype.mssqlserver2008, "server=localhost, initial catalog=permissions, integrated security=sspi;")
... works, problem configuration. doing wrong?
ok based off couple of boneheaded things did, , genuine lack of understanding on other things.
boneheaded thing #1: generating file other name looking for. nice job, jeremy.
boneheaded thing #2: had namespace elements in config file; it's not nhibernate.dialect.nhibernate.dialect.sqlitedialect
, it's nhibernate.dialect.sqlitedialect
.
genuine misunderstanding: thought activerecordsectionhandler
meant instantiated; turns out, needed static property of instance
work. should have looked is:
activerecordstarter.initialize(typeof(ipermissionsmanager).assembly, activerecordsectionhandler.instance);
voila! test passes.
Comments
Post a Comment