.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

java - Ebean enhancement ignores a model -

ubuntu - How to disable Kernel Module Signing in linux -

SQL php on different pages to Insert (mysqli) -