How to update a property on a parameter using FakeItEasy

守給你的承諾、 提交于 2019-12-02 01:13:21
Patrik Hägne

As you say, this is probably not the best practice. That aside, I guess you could do something like this:

A.CallTo(() => fake.ExecuteSqlCommand(A<string>._, A<SqlParameter[]>._))
    .Invokes((string s, SqlParameter[] p) => p[someIndex].Value = yourValue);

Or, using a less-readable but more powerful overload, access a IFakeObjectCall directly:

A.CallTo(() => fake.ExecuteSqlCommand(A<string>._, A<SqlParameter[]>._))
    .Invokes(callObject => callObject.GetArgument<SqlParameter[]>("parameters")[someIndex].Value = yourValue);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!