Is there a way to specify NOTHING as an argument to invoke NUnit Mocks Expect?

I am using NUnit mocks and would like to indicate that I am expecting a call, but without saying that there will be arguments, for example:

mock.ExpectAndReturn("Equals", true, ANY_ARGUMENT);

Obviously filling in the correct syntax instead of ANY_ARGUMENT.

Is there any way to do this?

If I do not specify any arguments, NUnit will end the test because it was expecting 0 arguments, but received 1.

+5
source share
4 answers

Looking at version 2.5.2 of nunit.mocks.dll in Reflector, a method does not appear that does what you are looking for. NUnit is open source, so one option is to get the code and add a feature.

+2
source

, NUnit Mocks .

ExpectAndReturn SetReturnValue. , , . .

: interfaceMock.SetReturnValue("SomeRetrunFunction", someReturnFunction);

+2

:

mock.SetReturnValue(true);
mock.Expect("Equals");
+1

IResolveConstraint, - . NUnit IResolveConstraint , , Assert.That Assert.AreEqual, .

Eg.

myMock.ExpectAndReturn( "mockedMethod", argument1, new AcceptsAnythingConstraint())

0

All Articles