Add a ctor to the fixture, taking the conn string, and capture it as a field. 
Then you can use it in the setup, tear down and tests. (You may need to remove 
the parameter from the test declarations).

Does that make sense?

On 25 Feb 2012, at 22:03, pascal <[email protected]> wrote:

> How can I get the connection string injected as parameter for a method
> having the [TearDown] attribute ?
> 
> On 22 Feb., 18:07, Graham Hay <[email protected]> wrote:
>> The approach I proposed on
>> StackOverflow<http://stackoverflow.com/questions/9348536/migration-from-mbunit-v2-t...>works
>> for me with Gallio
>> 3.3.458.0 <http://mb-unit.googlecode.com/files/GallioBundle-3.3.458.0.zip>.
>> Try the attached solution.
>> 
>> On 21 February 2012 09:48, pascal <[email protected]> wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> 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.
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "MbUnit.User" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/mbunituser?hl=en.
>> 
>> 
>> 
>> ProviderFactory.zip
>> 1408KAnzeigenHerunterladen
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "MbUnit.User" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/mbunituser?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/mbunituser?hl=en.

Reply via email to