On 25 Mag, 18:00, querpfeife <[EMAIL PROTECTED]> wrote:
> I could at the moment. But I thought, as it is an interface I am
> testing, that I may have a second implementation soon and so it would be
> easier to just add one more line to the factory than to change
> everything into a new test.

You are absolutely rigth,
I thougth that you can use a workaround to have always a new "fresh"
instance of your interface:
instead of passing directly your interface implementation to the test
method, you can pass a factory of your interface,
and in the test method obtain the implementtation using its factory
method.
So you'll have, the always the same instance of your factory which
produce always a new fresh instance.
Like this:

([UsingFactories("GetFactoryOfCompasIdentity")] ICompasIdentityFactory
cidFactory,
[UsingFactories("MakeCorrectName")] string name)
        {
            CompasIdentity cid = cidFactory.getInstance();
            Assert.IsTrue(cid.SetName(name),name+" ist
"+name.Length.ToString()+" Zeichen lang. Username:"+cid.Name);
            Assert.AreEqual(cid.Name, name);
        }

and the factory definition:

         [Factory(typeof(ICompasIdentityFactory ))]
        public IEnumerable GetFactoryOfCompasIdentity()
         {
            yield return new CompasIdentityFactoryImpl1();
            // If you want to add other impl of ICompasIdentity add
other factories
            //yield return new CompasIdentityFactoryImpl2();
         }

the factory method of CompasIdentityFactory will be something like
return new CompasIdentityImpl()

maybe it should work?

bye!


--~--~---------~--~----~------------~-------~--~----~
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