.net - How can I assert that a method of a specific class was called before another method of another class? -
here goes example of have:
public class classtobetestedtest { private mock<iaservice> aservice; private mock<ianotherservice> anotherservice; private classtobetested testedclass; [setup] public void setup() { aservice = new mock<iaservice>(); anotherservice = new mock<ianotherservice>(); testedclass = new classtobetested(aservice.object, anotherservice.object); } [test] public void shouldcallaservicemethodbeforeanotherservice() { testedclass.run(); aservice.verify(x=>x.amethod(), times.once()); anotherservice.verify(x=>x.anothermethod(), times.once()); } }
in sample check if called, no mather sequence...
im considering setup callback in methods add kind of sequence control in test class...
edit: i'm using moq lib: http://code.google.com/p/moq/
rhino mocks supports orders in mocking, see http://www.ayende.com/wiki/rhino+mocks+ordered+and+unordered.ashx
or moq sequences perhaps, http://dpwhelan.com/blog/software-development/moq-sequences/
see here similar question on this, how test method call order moq
Comments
Post a Comment