【问题标题】:NUnit and Moles errorNUnit 和 Moles 错误
【发布时间】:2011-10-03 19:08:53
【问题描述】:

我正在尝试使用 Moles 运行 NUnit,但遇到了一个奇怪的错误,我不太清楚为什么。

    [Test]
    [Moled]
    public void SendEmail_Test()
    {
        SIEmailService emailService = new SIEmailService
                                            {
                                                SendMailStringStringString = (email, subject, body) => { }
                                            };

        SIServiceLocator serviceLocator = new SIServiceLocator();
        serviceLocator.GetInstance(() => emailService);

        MLocatorFactory.GetInstance = (() => serviceLocator);


        IEmailservice = new EmailService();
        service.SendEmail("someone@there.com", null, null, null, DateTime.Now, null);
    }

错误:

关于如何解决这个部分受信任的调用者问题的任何建议????非常感谢。

【问题讨论】:

    标签: c# nunit moles


    【解决方案1】:

    添加到您的测试程序集AllowPartiallyTrustedCallersAttribute。但我不确定它为什么需要这个。您可能是从网络共享运行测试吗?

    【讨论】:

    • 不,没有网络共享试图设置示例,以说服团队使用 Moles.... 进展不顺利。现在学习更多关于说服他们给我们 MSTest,因为这太烦人了。我会看你的链接谢谢你的快速回复。
    • 好的,所以我尝试将 [assembly: AllowPartiallyTrustedCallers] 作为属性添加到我的测试文件中,但仍然收到相同的错误消息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    相关资源
    最近更新 更多