代碼如下:IServiceCollection services = new ServiceCollection();var mock = new Mock<IHostingEnvironment>();
mock.Setup(env => env.ContentRootPath).Returns(Directory.GetCurrentDirectory());請問如何注入IHostingEnvironment的mock實(shí)例mock.Object?
1 回答

GCT1015
TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊
services.AddTransient<IHostingEnvironment>(_ => mock.Object);
- 1 回答
- 0 關(guān)注
- 905 瀏覽
添加回答
舉報(bào)
0/150
提交
取消