Re: nunit-developer Digest, Vol 22, Issue 23
"Kelly Anderson" <[email protected]> Tue, 18 Mar 2008 13:33:00 -0600
| Newsgroups | gmane.comp.windows.dotnet.nunit.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Mar 18, 2008 at 11:44 AM, Gary Evans <[email protected]> wrote: > > > For dynamic data, I'm thinking of supporting something > > like this... > > > > [TestFixture] > > public class DynamicDataSample > > { > > [Test, DataSource( typeof(MyDataSource)] > > public void DivisionTest(double numerator, double denominator, > > double result) > > { > > Assert.AreEqual(result, numerator / denominator, 0.00001); > > } > > } > > > > Where MyDataSource is a class provided by the user. I'm > > still working on the details of this, so please throw in > > your ideas. I'd like to have a typesafe interface for > > data, rather than using a string. > > > > More to come on this - your comments are welcome. > > > > Hi Charlie, > > Passing in a type means that an instance of that type will be instantiated, > and using some interface the data will be extracted from that instance. > > I think this is good for the in-built DataSource attibute, but the > underlying extension point won't rely on that mechanism? I'm of course > thinking of my parameterized fixtures, where the test data comes from the > instance of the fixture... DataSource has five functions you have to override... class x : DataSource { #region DataSource Members public object getDataMember(string bstrDM, ref Guid riid) { } public string getDataMemberName(int lIndex) { } public int getDataMemberCount() { } public void addDataSourceListener(DataSourceListener pDSL) { } public void removeDataSourceListener(DataSourceListener pDSL) { } #endregion } That seems like an awful lot of messing around just to be type safe. And I'm wondering just how type safe that even makes things. The other problem I see with this is getDataMemberCount implies that you know the number of elements before hand, which you won't always. Perhaps we could create an NUnit interface that's more appropriate to the task at hand instead of trying to reuse this Microsoft interface.... unless there's some huge advantage to using it that I don't see at this point. If it's that it can come from a database or XML file or something, I think that adds a lot of complexity. -Kelly ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/