In the next build of v3.0.6 you can add this:

        protected override void ValidateSource(IPatternScope scope,
ICodeElementInfo codeElement) 
        {
        }

Jeff.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of max2256
Sent: Wednesday, February 18, 2009 8:43 AM
To: MbUnit.User
Subject: MbUnit Re: CsvData problem


Thanx, this it exactly what I need....when I run the a test using the custom
attribute I get an error saying that :

"At least one source property must be specified." for my custom attribute !



On Feb 17, 1:53 pm, "Jeff Brown" <[email protected]> wrote:
> Here's one way:
>
> public class CustomCsvDataAttribute : CsvDataAttribute {
>     protected override OpenTextReader(ICodeElementInfo codeElement)
>     {
>         string filePath = Config.GetMyConfigFilePath(); // or whatever
>         return File.OpenText(filePath);
>     }
>
> }
>
> Then:
>
> [Test, CustomCsvData]
> public void MyTest() { ... }
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] 
> On
>
> Behalf Of max2256
> Sent: Tuesday, February 17, 2009 9:53 AM
> To: MbUnit.User
> Subject: MbUnit Re: CsvData problem
>
> So I can be able to change the CSV file of my tests without 
> recompiling the code.
>
> e.g. I would have a folder containing multiple CVS files with data
>
>       DATA
>         |__ data1.csv
>         |__ data2.csv
>         |__ data3.csv
>
> In my config file I would specifie the csv file to use and I would not 
> need to recompile!
>
> Max
>
> On Feb 16, 2:47 pm, "Jeff Brown" <[email protected]> wrote:
> > I'm sorry, this is not supported by the C# language or .Net runtime.
> > Attribute properties can only be set to compile-time constants.
>
> > Why do you need to pull the path from a configuration file?
>
> > Jeff.
>
> > -----Original Message-----
> > From: [email protected] 
> > [mailto:[email protected]]
> > On
>
> > Behalf Of max2256
> > Sent: Monday, February 16, 2009 7:21 AM
> > To: MbUnit.User
> > Subject: MbUnit Re: CsvData problem
>
> > Hi,
>
> >    I would like to know if there is a workaround on setting the CSV 
> > path attribute from an config file?
> >    Let me explain with an example :
>
> >    public class Person
> >     {
> >         [CsvData(FilePath = Config.getCsvPerson() , HasHeader = 
> > true)]
> >         public Person(string name) {  }
> >     }
>
> >    If I currently run this I get the following compilation error :
> >    An attribute argument must be a constant expression, typeof 
> > expression or array creation expression
>
> > Thank you
>
> > On Feb 7, 5:09 am, "Jeff Brown" <[email protected]> wrote:
> > > On the fixture class.
>
> > > But it should also work on the constructor as well as on the 
> > > constructor parameter.  It can also be used on fields and 
> > > properties as well as individual test methods!
>
> > > Jeff.
>
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[email protected]]
> > > On
>
> > > Behalf Of max2256
> > > Sent: Monday, February 02, 2009 5:26 AM
> > > To: MbUnit.User
> > > Subject: MbUnit Re: CsvData problem
>
> > > What do you mean by putting it on the type?
>
> > > On Jan 31, 4:03 pm, Jeff Brown <[email protected]> wrote:
> > > > That's a bug.  We should be able to apply the attribute to the 
> > > > constructor.  However, try putting it on the type instead.
>
> > > > On Jan 29, 2009, at 2:35 PM, max2256 <[email protected]> wrote:
>
> > > > > Hi
>
> > > > > I have the following values in my csv file
>
> > > > > firstName,LastName,age
> > > > > Jim,Morrison,40
> > > > > Pat,King,25
>
> > > > > Now let's say I want to use the CsvData attribute this way:
>
> > > > > public class PersonTest
> > > > > {
> > > > >     private Person p;
>
> > > > >     [CsvData(FilePath = "Persons.csv", HasHeader = true)]
> > > > >     public PersonTest( string fName, string lName, int age )
> > > > >     {
> > > > >          p = new Person(fName,lName,age);
> > > > >     }
> > > > > }
>
> > > > > I've noticed that it is not possible to use le CsvData 
> > > > > attribute at the constructor level, the only way of achieving 
> > > > > this is with the following :
>
> > > > >   public PersonTest( [CsvData(FilePath = "Persons.csv", 
> > > > > HasHeader = true)] string fName, string lName, int age )
>
> > > > > My question is how can I get the lName and age value if I only 
> > > > > put the CsvData attribute only on the first parameter ?
>
> > > > > Thanx- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


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