我有一个AccountController,它的构造函数采用从我的自定义IOpenIdAuthentication接口派生的对象。默认情况下,这是一个包装OpenIdRelyingParty的OpenIdAuthenticationService对象。界面如下所示:
public interface IOpenIdAuthentication {
IAuthenticationResponse Response { get; }
IAuthenticationRequest CreateRequest(string identifier);
}
我可以模拟IAuthenticationResponse:
_mockResponse = new Mock<IAuthenticationResponse>(MockBehavior.Loose);
_mockResponse.SetupGet(r => r.ClaimedIdentifier).Returns(identifier);
_mockResponse.SetupGet(r => r.Status)
.Returns(AuthenticationStatus.Authenticated);
// ... removed the formatting of 'friendlyId' ...
_mockResponse.SetupGet(r => r.FriendlyIdentifierForDisplay).Returns(friendlyId);
但是,我不确定如何模拟IAuthenticationRequest,因为它看起来要复杂得多。有任何想法吗?