如何使 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 關注
- 106 瀏覽
添加回答
舉報
0/150
提交
取消