Making the class abstract really should be sufficient...

Jeff. 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of mark Kharitonov
Sent: Sunday, August 23, 2009 1:37 PM
To: [email protected]
Subject: MbUnit Re: How to correctly implement a generic base type
generating dynamic tests for some derived type?


No can do.
I tried it. Does not help. Exactly the same result.

I have, however, found a workaround to serve my narrow needs, which is to
invent another attribute:
===========================================================
  [AttributeUsage(AttributeTargets.Class, Inherited = true)]
  public sealed class EntityFrameworkTestFixtureAttribute :
TestTypePatternAttribute
  {
    public override void Consume(IPatternScope containingScope,
ICodeElementInfo codeElement, bool skipChildren)
    {
      ITypeInfo type = (ITypeInfo)codeElement;
      if (!type.IsGenericTypeDefinition)
      {
        base.Consume(containingScope, codeElement, skipChildren);
      }
    }
    public override bool IsPrimary
    {
      get { return true; }
    }
  }
===========================================================
Using this attribute on the BaseDynamicEntities<T> type while removing the
TestFixture from the derived DynamicEntities type solves it.

But this is just a hack. I would like to know the right way.
Thanks.


On 8/23/09, Jeff Brown <[email protected]> wrote:
>
> Make the class abstract.
>
> [TestFixture] is optional in v3.  MbUnit guesses that a class is a 
> test fixture if it is not abstract and contains tests.
>
> Jeff.
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] 
> On Behalf Of Mark Kharitonov
> Sent: Sunday, August 23, 2009 1:48 AM
> To: MbUnit.User
> Subject: MbUnit How to correctly implement a generic base type 
> generating dynamic tests for some derived type?
>
>
> Hi.
> Given:
>  * A generic base type, let us say BaseDynamicEntities<T>, which is 
> NOT marked with [TestFixture]. It does implement a static test factory 
> which generates dynamic tests using the generic type parameter T as 
> the source of some vital information.
>  * A non generic test fixture DynamicEntities deriving from 
> BaseDynamicEntities<T>, passing some concrete type in T.
>
> Problem:
> When run with the Gallio task, the task wants to run 
> BaseDynamicEntities<T> as though it was a test fixture, although it is 
> not marked so. Naturally it fails. The problem is that the whole task 
> is failed, despite the fact that all actual test fixtures do pass.
>
> The report created by the same run, on the other hand, is not red, but 
> rather gray. It indicates that the BaseDynamicEntities`1 is "skipped 
> because it is parameterized but no data was provided."
>
> The net effect is that msbuild fails, which is very wrong. My question 
> is why BaseDynamicEntities<T> is considered to be a test fixture in 
> the first place? After all, it is not attributed with TestFixture and 
> has no test fixture base types. How can I prevent the unit test 
> framework from treating it as a test fixture, yet preserving all the 
> dynamic test generation code in it?
>
> BTW, BaseDynamicEntities`1 is missing in the summary. One must browse 
> the details to look for it - this is the issue I have reported in one 
> of the previous posts.
>
> Jeff, I will send the repro steps to your google account right away.
>
>
> >
>


--
Be well and prosper.
==============================
"There are two kinds of people.Those whose guns are loaded and those who
dig."
   ("The good, the bad and the ugly")
So let us drink for our guns always be loaded.



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