LoginSignup
4
2

More than 5 years have passed since last update.

MSTestでプライベートメソッドの参照渡しをテストする

Last updated at Posted at 2018-09-19

VS2015のMSTestで、StaticでPrivateなメソッドをテストするのにPrivateTypeのInvokeStaticを使用している。
ただ、メソッドの引数が参照渡しの場合、パースが通りません。

ダメな例。refキーワードは付けられない。
p.InvokeStatic("GetFiles", Dirpath, Ref No);

こう書いたら解決しました。

object配列で引数を渡す。できました。
object[] args = new object[] { Dirpath, null };
p.InvokeStatic("GetFiles", args);
No = args[1] 'argsに参照値が入る
4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2