如何使 Moq 库与 .NET core Preview 3.x 一起使用?有可能吗?具体来说,当我启用 Moq 时,与日志库发生冲突:MyProjectTest.cs(25, 45): [CS1705] :Assembly 'MyProject' with identity 'MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.Extensions.Logging.Abstractions' with identity 'Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
1 回答
江户川乱折腾
TA贡献1851条经验 获得超5个赞
编辑:问题的更新版本与 无关Moq
。您需要确保所有依赖项均已正确更新。Microsoft.Extensions.Logging.Abstractions
没有被 引用Moq
。
Edit2:这里有一个示例。
对的,这是可能的。当前版本(截至目前 4.12.0)支持 .NET-Standard 2.0。.NET-Core 3.0 完全支持这一点,因此您可以像往常一样使用它。
var mock = new Mock<ISomeService>(MockBehavior.Loose); mock.Setup(someService => someService.IsValidString(it.IsAny<string>) .Returns(true);
- 1 回答
- 0 关注
- 78 浏览
添加回答
举报
0/150
提交
取消