我最近開始學習Fluent NH,並且在測試方法上遇到了一些麻煩。它需要永遠運行(現在已經運行了十多分鐘,並沒有進展的跡象......)。流利的NHibernate映射測試需要永久
[TestMethod]
public void Entry_IsCorrectlyMapped()
{
Action<PersistenceSpecification<Entry>> testAction = pspec => pspec
.CheckProperty(e => e.Id, "1")
.VerifyTheMappings();
TestMapping<Entry>(testAction);
}
與這個輔助方法(稍作簡化 - 我有一對夫婦try/catch塊太大,以提供更好的錯誤消息):
public void TestMapping<T>(Action<PersistenceSpecification<T>> testAction) where T : IEntity
{
using (var session = DependencyFactory.CreateSessionFactory(true).OpenSession())
{
testAction(new PersistenceSpecification<T>(session));
}
}
的DependencyFactory.CreateSessionFactory()
方法是這樣的:
public static ISessionFactory CreateSessionFactory(bool buildSchema)
{
var cfg = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory())
.Mappings(m => m.FluentMappings.AddFromAssembly(typeof(Entry).Assembly));
if (buildSchema)
{
cfg = cfg.ExposeConfiguration(config => new SchemaExport(config).Create(false, true));
}
return cfg.BuildSessionFactory();
}
我試過調試過,但是我找不出瓶頸在哪裏。爲什麼這需要這麼長時間?
有多長 '長'?範圍內有多少映射? – 2010-01-09 01:56:47
我說了十分鐘,但現在已經過了半個多小時 - 測試跑步者仍然說「正在進行......」。到目前爲止,只有兩種映射 - 兩者都非常簡單。 – 2010-01-09 02:13:44