[英]Moq library and .NET core preview 3.0
How can I make the Moq library work with .NET core preview 3.x ? 如何使Moq库与.NET Core Preview 3.x一起使用? Is it possible at all?
有可能吗?
Specifically, when I enable Moq there is a conflict with the logging library: 具体来说,当我启用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'
Edit: The updated version of the question has nothing to do with Moq
. 编辑:问题的更新版本与
Moq
无关。 You need to make sure that all dependencies are updated properly. 您需要确保所有依赖项都已正确更新。
Microsoft.Extensions.Logging.Abstractions
is not referenced by Moq
. Moq
未引用Microsoft.Extensions.Logging.Abstractions
。
Edit2: Here a sample . 编辑2:这是一个示例 。
Yes, it is possible. 对的,这是可能的。 The current version (as of now 4.12.0), supports .NET-Standard 2.0.
当前版本 (截止到4.12.0)支持.NET-Standard 2.0。 That is fully supported by .NET-Core 3.0 so you would use it like you always did.
.NET-Core 3.0完全支持该功能,因此您将像往常一样使用它。
var mock = new Mock<ISomeService>(MockBehavior.Loose);
mock.Setup(someService => someService.IsValidString(it.IsAny<string>)
.Returns(true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.