从 MBUnit v2 迁移到 v3,ProviderFactory 消失了
在 MBUnit v2 中,我这样做了:
public class ConnectionStringFactory
{
[Factory]
public string ConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
}
}
}
[ProviderFactory(typeof(ConnectionStringFactory),typeof(string))]
public class CustomerTests
{
public void GetCustomerTest(string connectionString)
{
}
public void GetCustomersTest(string connectionString)
{
}
}
我必须创建一个 Factory 类,返回一个连接字符串,该连接字符串被注入到单元测试类的每个测试方法中。
如何使用 ProviderFactory 消失的 MBUnit v3 来完成此操作?
我在 Factory 类上玩了很多,但结果不是我想要的。
我想要一个由所有测试类使用的连接字符串工厂,其中连接字符串
自动注入到每个测试方法中。
In MBUnit v2 I did this:
public class ConnectionStringFactory
{
[Factory]
public string ConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
}
}
}
[ProviderFactory(typeof(ConnectionStringFactory),typeof(string))]
public class CustomerTests
{
public void GetCustomerTest(string connectionString)
{
}
public void GetCustomersTest(string connectionString)
{
}
}
I had to create ONE Factory class returning me a connectionString which gets injected into each test method of a unit test class.
How can this be done with MBUnit v3 where the ProviderFactory is gone?
I played a lot with the Factory class, but the result is not what I want.
I want to a Connection string factory used by all test classes where the connection string
is injected into each test method automatically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个怎么样?
How about this?