通过使用 ReturnsForAnyArgs() 方法,可以设置当一个方法被调用后,无论参数是什么,都返回指定的值。


ReturnsForAnyArgs() 具有与 Returns() 方法相同的重载,所以也可以指定多个返回值,或者计算返回值。
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_get_started.html">(一)入门基础</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_creating_a_substitute.html">(二)创建替代实例</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_setting_a_return_value.html">(三)设置返回值</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_return_for_specific_args.html">(四)为特定参数设置返回值</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_return_for_any_args.html">(五)为任意参数设置返回值</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_return_from_a_function.html">(六)使用函数设置返回值</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_multiple_return_values.html">(七)设置多个返回值</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_replacing_return_values.html">(八)替换返回值</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_checking_received_calls.html">(九)检查接收到的调用</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_clearing_received_calls.html">(十)清理已收到的调用</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_argument_matchers.html">(十一)参数匹配器</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_callbacks_void_calls_and_when_do.html">(十二)使用回调函数和WhenDo语法</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_throwing_exceptions.html">(十三)抛出异常</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_raising_events.html">(十四)引发事件</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_auto_and_recursive_mocks.html">(十五)自动递归模拟</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_setting_out_and_ref_args.html">(十六)设置out和ref参数</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_actions_with_argument_matchers.html">(十七)参数匹配器上的操作</a>
<a href="http://www.cnblogs.com/gaochundong/archive/2013/05/22/nsubstitute_checking_call_order.html">(十八)检查调用顺序</a>
本文转自匠心十年博客园博客,原文链接:http://www.cnblogs.com/gaochundong/archive/2013/05/21/nsubstitute_return_for_any_args.html,如需转载请自行联系原作者