恕我直言,RhinoMocks在使用AssertWasCalled时会产生一条不清楚的诊断消息,以验证是否已使用特定参数调用方法。例子:interfaceISomeInterface{voidWrite(strings);}[TestFixture]publicclassSomeTests{[Test]publicvoidWriteShouldBeCalledWithCorrectArguments(){//Arrangevarmock=MockRepository.GenerateMock();varsut=newSomeClass(mock);//Actsut.DoSomethin
使用RhinoMocks-我可以获取被调用函数的参数吗?我是说;我可以从函数调用中获取一些未知参数吗?我有一个模拟,我希望在这个模拟上调用一些函数。我知道其中一个参数,但另一个参数是未知的,因为它来自使用模拟并在其上调用函数的类。更具体地说——在这种情况下——未知参数是一个lambda函数。这是一个回调函数,应该在函数完成执行时调用。由于模拟阻止调用回调,我想获取它并自己调用它。所以;我想检查函数是否被调用。我想确保一些论点是预期的。我想找出未知的参数,然后再对它们进行一些操作。假设两个参数都是整数(为简单起见)我想做这样的事情:intunknownInt;_fakeSomething
我一直在四处寻找有关使用AAA语法使用RhinoMocks3.5+的一些不错的信息。我发现很多博客混合了新旧事物,这似乎让弄清楚如何使用它变得更加困难。如果有像早期版本那样的RhinoMocksAAA备忘单就好了。是否需要了解旧版Rhino的所有知识才能实际使用新版?我敢肯定,如果我是专家,我会喜欢Rhino的所有功能,但现在我只是沉浸在信息中。任何指针或好的链接将不胜感激! 最佳答案 我写了一个RhinoMocksArrange/Act/Assert(AAA)SyntaxQuickReference.它包含从Ayende'sweb
以下测试用例在rhino模拟中失败:[TestFixture]publicclassEnumeratorTest{[Test]publicvoidShould_be_able_to_use_enumerator_more_than_once(){varnumbers=MockRepository.GenerateStub();numbers.Stub(x=>x.GetEnumerator()).Return(newList{1,2,3}.GetEnumerator());varsut=newObjectThatUsesEnumerator();varcorrectResult=sut.
我有这个代码:Expect.Call(factory.CreateOrder()).Return(newOrder()).Repeat.Times(4);当它被调用四次时,每次都返回相同的实例。我想要返回不同的实例。我希望能够做类似的事情:Expect.Call(factory.CreateOrder()).Return(()=>newOrder()).Repeat.Times(4);这可以通过某种方式完成吗? 最佳答案 而不是使用.Return(newOrder());尝试使用.Do((Func)delegate(){return
我一直在尝试使用文件流来模拟使用,但未能完成此操作并且我不确定该怎么做,我正在使用rhino模拟。privateConnectionLoadConnectionDetailsFromDisk(stringbodyFile){//logicbeforeusing(FileStreamfs=File.Open(bodyFile,FileMode.Open,FileAccess.Read,FileShare.ReadWrite)){returnthis.serverConfiguration.LoadConfiguration(fs,flowProcess);}//morelogic}谁能告
嘿,人们很想知道您拥有或了解的有关nServiceBus、RhinoServiceBus和MassTransit的任何资源。视频?博客文章?书?演示项目等 最佳答案 如果您对公共(public)交通感兴趣,可以看看:GettingStartedandDocumentationElegantcodePodcast如果您使用structuremapDruSellersBlogChrisPattersonBlogTheirGoogleGroups在某些时候你会得到http://codebetter.com/blogs/dru.seller
我有一个TimeMachine类,它为我提供当前日期/时间值。该类看起来像这样:publicclassTimeMachine{publicvirtualDateTimeGetCurrentDateTime(){returnDateTime.Now;};publicvirtualDateTimeGetCurrentDate(){returnGetCurrentDateTime().Date;};publicvirtualTimeSpanGetCurrentTime(){returnGetCurrentDateTime().TimeOfDay;};}我想在我的测试中使用TimeMachin
模拟对WCF服务的调用时,出现以下错误:Method'ICustomerEntities.GetCustomerFromPhoneNumber("01234123123");'requiresareturnvalueoranexceptiontothrow.我用谷歌搜索并在这里搜索-我能找到的只是我需要重新订购各种电话等,但在我的情况下这似乎没有意义?也许有人可以向我指出它实际上确实?我的测试设置是这样的_entities=MockRepository.GenerateStrictMock();并且第三行测试方法失败,设置result2_entities.Expect(ip=>ip.G
如何使用RhinoMocks模拟索引属性? 最佳答案 我假设您指的是使用this[]的属性varmockClass=MockRepository.GenerateMock();mockClass.Expect(m=>m["key"]).Return("value");//returnavaluemockClass.Expect(m=>m["key2"]="value2");//setavalue...sometestinhereusingsomethingthatdependsonmockClass...mockClass.Veri