我在 IIS 上运行我的应用程序以测试我的服务是否按预期工作。此外,我对其他内部类的操作进行单元测试。
以下是我的会话工厂配置:
Fluently.Configure()
.Database(MySQLConfiguration.Standard
.ConnectionString(myconnectionString)
.ShowSql()
)
.CurrentSessionContext<WcfOperationSessionContext>()
//.CurrentSessionContext("call")
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<DtoDifficulty>())
.BuildSessionFactory();
您可以注意到注释行,带有//.CurrentSessionContext("call")。当我在 IIS 上运行我的服务时,我必须使用它上面的行.CurrentSessionContext< WcfOperationSessionContext >(),当我运行单元测试时,.CurrentSessionContext("call")。
有没有办法知道哪个案例正在运行并自动设置其中一个选项?