views:

91

answers:

1

Hello,

I was wondering how I can mock the ClaimseReponse class in DotNetOpenAuth?

This is the class(remove a few properties):

[Serializable]
public sealed class ClaimsResponse : ExtensionBase, 
                                     IClientScriptExtensionResponse,
                                     IExtensionMessage, 
                                     IMessageWithEvents, 
                                     IMessage
{
    public static bool operator !=(ClaimsResponse one, ClaimsResponse other);
    public static bool operator ==(ClaimsResponse one, ClaimsResponse other);

    [MessagePart("email")]
    public string Email { get; set; }
    [MessagePart("fullname")]
    public string FullName { get; set; }

    public override bool Equals(object obj);
    public override int GetHashCode();
}

This is what I tried:

ClaimsResponse MockCR = new ClaimsResponse();
MockCR.Email = "[email protected]";
MockCR.FullName = "Mister T";

I get the following error: '...ClaimsResponse(string)' is inaccessible due to its protection level.

Kind regards,

Pickels

+1  A: 

Wrong answer - correct answer in comments

You have to create it through a ClaimsRequest object:

ClaimsRequest request = new ClaimsRequest();
ClaimsResponse response = request.CreateResponse();
Andrew Arnott
Thanks for the answer and your hard work on DotNetOpenAuth.
Pickels
When I try that I get the following error:failed: System.InvalidOperationException : A Simple Registration request can only generate a response on the receiving end.
Pickels
Oh, whoops. Sorry. You're right. I guess there's no public way to create a `ClaimsResponse`. DotNetOpenAuth reserves the exclusive capability of doing that internally.
Andrew Arnott