I should say that I'm fairly new in the mock-framework world of C#. I'm building a small service that listens to incoming HTTP requests using a System.Net.HttpListener
and would like to unit test my implementation by injecting a mock instance of that class. So I tried using Moq , but that of course requires that the mock target is an interface so that it can provide a stub implementation. Then I tried using Microsoft Fakes, but it won't let me generate a StubHttpListener
. So is there any other way to mock the behaviour of System.Net.HttpListener
?
写一个包装HttpListener的类并从中提取一个接口,然后可以模拟/存根包装器
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.