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.
See Question&Answers more detail:os