Pregunta

Tengo un AccountController , cuyo constructor toma un objeto derivado de mi costumbre IOpenIdAuthentication interfaz. Por defecto, este es un OpenIdAuthenticationService objeto que envuelve un OpenIdRelyingParty . La interfaz se parece a esto:

public interface IOpenIdAuthentication {
    IAuthenticationResponse Response { get; }
    IAuthenticationRequest CreateRequest(string identifier);
}

Puedo burlarse 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);

Sin embargo, no estoy seguro de cómo se burlan IAuthenticationRequest como aparece mucho más complicado. ¿Alguna idea?

¿Fue útil?

Solución

No es mucho más complicado. Si usted está haciendo sólo la autenticación, entonces burlarse RedirectToProvider () sería suficiente. En el caso más simple que parece:

_mockRequest = new Mock<IAuthenticationRequest>(MockBehavior.Strict);
_mockRequest.Setup(r => r.RedirectToProvider());

Espero que esto ayude

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top