DotNetOpenAuth:Mock ClaimsResponse

时间:2010-04-12 20:12:44

标签: c# mocking dotnetopenauth

我想知道如何在DotNetOpenAuth中模拟ClaimseReponse类?

这是类(删除一些属性):

[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();
}

这就是我的尝试:

ClaimsResponse MockCR = new ClaimsResponse();
MockCR.Email = "hello@sayhi.com";
MockCR.FullName = "Mister T";

我收到以下错误:'... ClaimsResponse(string)'由于其保护级别而无法访问。

亲切的问候,

Pickels

1 个答案:

答案 0 :(得分:1)

错误答案 - 评论中的正确答案

您必须通过ClaimsRequest对象创建它:

ClaimsRequest request = new ClaimsRequest();
ClaimsResponse response = request.CreateResponse();