c# - DotNetOpenAuth:模拟 ClaimsResponse

标签 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)”由于其保护级别而无法访问。

亲切的问候,

泡菜

最佳答案

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

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

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

关于c# - DotNetOpenAuth:模拟 ClaimsResponse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2625084/

相关文章:

c#:如何以编程方式突出显示/删除 datagridview 中的行

c# - PowerShell 添加类型 : Cannot add type. 已存在

c# - 在 RESTful WebApi 请求上运行后台线程

c# - 单元测试中的部分模拟/伪造

python - 在单元测试中使用补丁模块时,自动完成 pycharm 不起作用

authentication - DotnetOpenAuth RefreshAuthorization 被阻止 403 禁止 (12202)

google-analytics - NativeApplicationClient.ClientIdentifier 未解析

c# - IComparable 和 Equals()

unit-testing - 当依赖项不公开接口(interface)时,在 GO 中模拟依赖项的最佳方法是什么

c# - 无法为 Facebook 创建 SSL/TLS 安全通道