c# - How to set universal path in method's attribute -


i wrote test. use data driven unit tests. method declaration looks follow:

[testcategory("integrationtest")] [datasource("microsoft.visualstudio.testtools.datasource.csv", "c:\\myprojectpath\\file.csv", "file#csv", dataaccessmethod.sequential), deploymentitem("file.csv"), testmethod] public void read_csv_file_attribute() 

i want commit changes source control. problem have hardcoded path in datasource attribute: "c:\myprojectpath\file.csv".

if latest version of code repository person have change path in attribute.

how make universal path work c-workers?


i've tried change path using:

methodinfo method = typeof(testclass).getmethod("read_csv_file_attribute"); method.customattributes.elementat(1).constructorarguments.elementat(1).value = _newpath; 

it doesn't work because value read-only.


[testcategory("integrationtest")] [datasource("microsoft.visualstudio.testtools.datasource.csv", path.combine(), "file#csv", dataaccessmethod.sequential), deploymentitem("file.csv"), testmethod] public void read_csv_file_attribute() 

combine() throws message: cannot resolve symbole 'combine'.


i tried use configurationmanager class, information: class name not valid @ point.

  1. include file.csv project , copy output directory (right click on file.csv in solution => properties => advanced => copy output directory => copy if newer)

  2. use relative path "file.csv" in datasourceattribute:

    [datasource("microsoft.visualstudio.testtools.datasource.csv",          "file.csv", "file#csv", dataaccessmethod.sequential)] 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -