Have you considered calling the Consume method yourself and building up a TestModel?
Jeff. On Wed, Mar 17, 2010 at 11:47 AM, mark Kharitonov <[email protected] > wrote: > Hi Jeff. > Thanks for the prompt reply. > > What are the reasons to hide the MetadataPatternAttribute.GetMetadata() > method? I mean, by just raising its scope to public my scenario would be > much simpler to implement... > > > > On Wed, Mar 17, 2010 at 8:18 PM, Jeff Brown <[email protected]> wrote: > >> In general, you'll find that several attributes add metadata without being >> descendants of MetadataAttribute. For example, [Ignore] and [Explicit] add >> IgnoreReason and ExplicitReason metadata, iirc. Also [Test] can have a >> Description which is encoded as Description metadata. >> >> Your use case just isn't something that the framework was intended to >> support. Long term, I'd like to unify the TestCase test construction >> mechanism with the attribute-based test construction mechanism more. That >> will help your use-case but it's not going to happen immediately. >> >> Sorry, >> Jeff. >> >> >> On Wed, Mar 17, 2010 at 7:54 AM, Mark Kharitonov < >> [email protected]> wrote: >> >>> Dear ladies and sirs. >>> >>> In my scenario I create dynamic tests, where each test wraps the >>> respective statically compiled test. It is essential, that any >>> metadata found on the static test will be copied to the respective >>> dynamic test. >>> >>> Quite conveniently, the TestCase type has Metadata dictionary. So, I >>> execute a code like this: >>> >>> var test = new TestCase(...); >>> var metadataAttrs = >>> >>> (MetadataAttribute[])methodInfo.GetCustomAttributes(typeof(MetadataAttribute), >>> false); >>> metadataAttrs.ForEach(m => test.Metadata.Add(m.MetadataKey, >>> m.MetadataValue)); >>> >>> BUT, CategoryAttribute is left out, because it does not derive from >>> MetadataAttribute, but from MetadataPatternAttribute! >>> >>> My question is why? The Category is still metadata and it is treated >>> internally as such. When I change the last line of the aforementioned >>> code sample to this: >>> >>> metadataAttrs.ForEach(i => >>> { >>> var c = i as CategoryAttribute; >>> if (c == null) >>> { >>> var m = (MetadataAttribute)i; >>> test.Metadata.Add(m.MetadataKey, m.MetadataValue); >>> } >>> else >>> { >>> test.Metadata.Add("Category", c.Category); >>> } >>> }); >>> >>> The dynamic tests are now treated as though they had the Category >>> attribute, when what I did is just added the "Category" metadata key >>> corresponding to the Category attribute. >>> >>> This Category-not-Metadata business makes the code more ugly. >>> >>> Another solution would be to raise the scope of the >>> MetadataPatternAttribute.GetMetadata() method from protected to >>> public. >>> >>> What do you think? >>> >>> -- >>> 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]<mbunituser%[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]<mbunituser%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/mbunituser?hl=en. >> > > > > -- > 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]<mbunituser%[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.
