Tag: function测试

ServiceStack AppHostHttpListenerBase无法连接到远程服务器

我正在我的应用程序上完成一些function测试,我想我已经非常接近了。 我的问题是,当我运行第一次测试时,我得到了错误。 无法连接到远程服务器。 预期:好的 但是:0 我可以确认,如果我在断言上设置断点,然后尝试在我的浏览器中点击BaseUrl ,则找不到它。 这是我的考试。 [Test] public void MyTestTest () { var client = new RestClient( ServiceTestAppHostBase.BaseUrl ); // client.Authenticator = new HttpBasicAuthenticator( NUnitTestLoginName, NUnitTestLoginPassword ); var request = new RestRequest( “/users/”, Method.GET ); request.RequestFormat = DataFormat.Json; var response = client.Execute( request ); // do assertions on the response object now Assert.That( […]

使用Moq模拟Func 构造函数参数并validation它是否被调用了两次

从这篇文章中获取问题( How to moq a Func )并对其进行了调整,因为答案不正确。 public class FooBar { private Func __fooBarProxyFactory; public FooBar(Func fooBarProxyFactory) { _fooBarProxyFactory = fooBarProxyFactory; } public void Process() { _fooBarProxyFactory(); _fooBarProxyFactory(); } } 我需要模拟一个作为构造函数参数传递的Func ,断言func被调用两次。 当试图模拟函数var funcMock = new Mock<Func>(); 由于Func类型不可模拟,因此Moq引发exception。 问题是,如果没有模拟func,就不可能validation函数被调用(n)次。 funcMock.Verify( (), Times.AtLeast(2));