NUnit和Moles错误

时间:2011-10-03 19:08:53

标签: c# nunit moles

我正在尝试使用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);
    }

错误:

The security issue that is being thrown

有关如何修复此部分受信任的来电者问题的任何建议????非常感谢。

1 个答案:

答案 0 :(得分:0)

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