假设方法为:
public async Task AddItem(string item, int id)
{
await AddToDataBase();
}
我如果要Mock的话,需要怎么操作?
相关问题
- Dotnet Core API - Get the URL of a controller meth
- Why am I unable to run dotnet tool install --globa
- Singleton with AsyncLocal vs Scope Service
- What would prevent code running in a Docker contai
- .NET Core gives unknown error while processing HTT
相关文章
-
EF6 DbSet
returns null in Moq - DotNet Core console app: An assembly specified in
- EF Core 'another instance is already being tra
- Re-target .NET Core to net471, net 472
- Publishing a Self-contained Console app fails
- Mocking indexed property
- Calling a .Net Framework 4 (or Mono) assembly from
- Can I use moq's InSequence() with MockBehavior
官方文档里面有案例,可以参考一下。
使用
似乎是可以的,但是代码中一直出现空引用错误,无奈下只好把方法加上<bool> 使用Returns<> 来返回就成了。
去官方文档里查看案例参考一下