.net - IEnumerable<T> as a DataSource for a data driven test -


is possible in .net create data driven test uses ienumerable<t> datasource?

the problem is:
there class want test. behavior differs, depending on int value receives constructor parameter.
, there static method returns ienumerable<int> of possible values constructor parameter.

have found solution. not satisfied it, works.

[datasourcegenerator("source.csv")] public class datadriventests {     public testcontext testcontext { get; set; }      [testmethod]     [datasource("microsoft.visualstudio.testtools.datasource.csv", "source.csv", "source#csv", dataaccessmethod.sequential)]     //the source generated automatically datasourcegenerator attribute     public void datadriventest()     {         //here can implement data driven test of own     } }  [attributeusage(attributetargets.class)] internal sealed class datasourcegeneratorattribute : attribute {     public datasourcegeneratorattribute(string filename)     {         var csvcontent = generatecsvcontent();          file.writealltext(filename, csvcontent);     }     private string generatecsvcontent()     {         //here can generate content csv     } } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -