如果这是一个重复的问题,我深表歉意(我没有找到类似的问题)。我正在尝试构建一个 OpenId 身份验证服务并对其进行单元测试,目前我有以下设置:
public class OpenIdAuthenticationService : IAuthenticationService
{
private IConfigurationService _configService;
private OpenIdRelyingParty _openIdRelyingParty;
public OpenIdAuthenticationService(IConfigurationService configService)
{
_configService = configService;
_openIdRelyingParty = new OpenIdRelyingParty();
}
}
显然 OpenIdRelyingParty 需要访问 HttpContext,有没有办法模拟 OpenIdRelyingParty 并将其注入服务?或者也许可以模拟 HttpContext 并以某种方式将其提供给 OpenIdRelyingParty ?