小编Sur*_*ian的帖子

如何模拟在单元测试函数中使用的 SmtpClient 对象

我想为 BatchProcess 中存在的 SendMail 方法编写 Nunit 或单元测试,而不发送邮件。

如何模拟另一种方法中存在的 SmtpClient。请帮忙。

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //Assuming we are populating the emails from the data from database
            List<EmailEntity> emails = new List<EmailEntity>();
            BatchProcess.SendMail(emails);
        }
    }

    public class EmailEntity
    {
        public string ToAddress { get; set; }
        public string Subject { get; set; }
        public string Body { get; set; }
    }

    public class BatchProcess
    {
        public static void SendMail(List<EmailEntity> emails)
        {
            foreach (EmailEntity email in emails) …
Run Code Online (Sandbox Code Playgroud)

c# nunit unit-testing moq mocking

2
推荐指数
1
解决办法
2301
查看次数

为什么 Azure 存储帐户有两个密钥?

为什么 Azure 存储帐户有两个密钥?请用一些实时例子来解释

azure azure-storage

1
推荐指数
2
解决办法
1433
查看次数

标签 统计

azure ×1

azure-storage ×1

c# ×1

mocking ×1

moq ×1

nunit ×1

unit-testing ×1