Lets say I have an attribute with a fairly long/complex list of parameters. For example:
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV","|DataDirectory|\\stores.csv","stores#csv", DataAccessMethod.Sequential)]
Is there a way to create a custom attribute as a shorthand for this, so that instead of typing the above for every method, I can just use [CustomDataSource]?
The DataSource attribute is sealed, you cannot inherit from it.
The easiest solution is to use constants:
public class Const
{
public const string Provider = "Microsoft.VisualStudio.TestTools.DataSource.CSV";
public const string ConnString = "|DataDirectory|\\stores.csv";
public const string Table = "stores#csv";
public const string Method = DataAccessMethod.Sequential;
}
[DataSource(Const.Provider, Const.ConnString , Const.Table , Const.Method)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With