How do I make a mockup of System.Net.Mail MailMessage?

前端 未结 4 471
庸人自扰
庸人自扰 2021-02-04 02:47

So I have some SMTP stuff in my code and I am trying to unit test that method.

So I been trying to Mockup MailMessage but it never seems to work. I think none of the met

4条回答
  •  时光说笑
    2021-02-04 03:32

    disclaimer: I work at Typemock Instead of finding some hack you can use Typemock Isolator to simply fake that class in only one line of code:

    var fakeMailMessage = Isolate.Fake.Instance();
    

    Then you can set behavior on it using Isolate.WhenCalled

提交回复
热议问题