我有一些代码可以下载一些 RSS 源.
I've got some code which downloads some RSS feeds.
我一直在使用 WebClient 或 Argotic.Syndication.RssFeed 库.
I've been using WebClient or Argotic.Syndication.RssFeed libraries.
但这些不是可模拟的 :(
我绝对不想每次运行单元测试时都点击真正的 RSS 提要.
I definately do not want to hit the real RSS feed every time I run the unit test.
有人对我能做什么有任何建议吗?
Does anyone have any suggestions to what I can do?
我需要创建一个邪恶的包装器吗?如果是这样.. 对此有何建议?
Do I need to create an evil wrapper? If so .. suggestions on this?
我会为每个外部依赖项创建一个包装器(如果可行的话).因此,与文件系统/网络服务/数据库的每次交互都应仅通过接口完成,这将产生更多可测试的代码.
I go for creating a wrapper for every external dependency (if it's practical). So, every interaction with the filesystem/a webservice/database should be done through an interface only, which will lead to more testable code.
另一个解决方案当然是(一如既往)Typemock Isolator.
Another solution of course is (as always) Typemock Isolator.
这篇关于需要一些建议来尝试模拟 .NET WebClient 或等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
ASP.NET Core 使用 Azure Active Directory 进行身份验证并ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 进行身
ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用)
ASP Core Azure Active Directory 登录使用角色ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登录使用角色)
如何获取守护进程或服务器到 C# ASP.NET Web API 的How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何获取守护进程或服务器到 C# ASP.N
.Net Core 2.0 - 获取 AAD 访问令牌以与 Microsoft Graph.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 获取 AAD 访问令牌以与 Microsoft Graph 一起使用)
异步调用时 Azure KeyVault Active Directory AcquireTokenAAzure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(异步调用时 Azure KeyVault Active Directory AcquireTokenAsync 超