phuccaoca123 / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

Add data binding, including support for generic parameters. #107

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Julian put forth this case.  And I've seen a similar request on the mailing
lists:

[UsingTypes(typeof(Foo), typeof(Bar))]
public void Test<T>() { }

Now that needs to be cleaned up a bit, because it would be ambiguous in the
case where we have multiple type parameters.  Moreover, there's no need to
have a special [UsingTypes] declaration, any plain old data source that can
produce a Type object should do fine.

So we can do this:

[Data(typeof(string), typeof(int), "abc", 42)]
public void Test<TKey, TValue>(TKey key, TValue value) { }

Where by convention we bind parameters including generic type parameters
from left to right.  This just involves a little fudging of the ordinal
indices of the generated ITestParameter objects.

And we can also apply data attributes to generic type parameters:

public void Test<[Data(typeof(string)), Data(typeof(int))] T>() { }

This opens up some interesting possibilities.  For example, we can imagine
generic test types that are created on the side and mixed in or reused by
binding values to the generic type parameters.

Worth thinking about.  But if we're going to put this in place, it has to
go in soon.

Original issue reported on code.google.com by jeff.br...@gmail.com on 10 Dec 2007 at 7:30

GoogleCodeExporter commented 9 years ago
Widened the scope of this bug to include all of the other missing data binding 
bits.
 Generic parameter support comes about as a nice side-effect of the underlying design.

Original comment by jeff.br...@gmail.com on 10 Jan 2008 at 10:27

GoogleCodeExporter commented 9 years ago

Original comment by jeff.br...@gmail.com on 29 Feb 2008 at 6:57