起订量类库

发布于 2025-01-17 13:43:17 字数 340 浏览 0 评论 0原文

我正在尝试找到一种适当的方法来订阅此问题,但我不确定如何做。这是一个.NET标准2.0库,必须从.NET 4.8和.NET CORE 3+消费。

这是一个例子。

private ILogService _logService;

public class Logger() :IProjectLogger
{
   _logService = new LogService();
}

在测试Logger()时,我想浏览IlogService方法。但是,由于这可能并不总是与依赖注入一起使用,而且我不希望客户必须注入ilogservice,因此我在测试Logger()

谢谢!

I'm trying to find an appropriate way to Moq this, and I'm unsure on how to do it.This is a .Net Standard 2.0 library that must be consumed from .net 4.8, and .net core 3+.

Here is an Example.

private ILogService _logService;

public class Logger() :IProjectLogger
{
   _logService = new LogService();
}

When testing Logger(), I would like to Moq the ILogService methods. But since this may not always be used with dependency injection, and I don't want the client to have to inject ILogService, I'm stuck on how to moq ILogService methods when testing Logger()

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文