这就是我希望能够做到的。
/// <summary>
/// Gets the session factory.
/// </summary>
/// <value>The session factory.</value>
public ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
#if(NUNIT)
_sessionFactory = Fluently.Configure()
.Database(SQLiteConfiguration.Standard
.UsingFile(DbFile)
.ShowSql())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<ForeignFormat>())
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
#else
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(c => c
.Server(".\\sqlexpress")
.Database("mPort")
.TrustedConnection())
.ShowSql()
)
.Mappings(m => m
.FluentMappings.AddFromAssemblyOf<ForeignFormat>())
.BuildSessionFactory();
#endif
}
return _sessionFactory;
}
}
如果您正在运行单元测试,是否可以 #if 条件?