В RhinoMocks вы можете просто сообщить своим макетам IgnoreArguments в качестве заявления об общем виде. В Moq, кажется, вы должны указать It.IsAny() для каждого аргумента. Однако это не работает для аргументов ref и out. Как я могу протестировать следующий метод, когда мне нужно выполнить Moq для внутреннего вызова службы, чтобы вернуть конкретный результат:
public void MyMethod() {
// DoStuff
IList<SomeObject> errors = new List<SomeObject>();
var result = _service.DoSomething(ref errors, ref param1, param2);
// Do more stuff
}
Метод тестирования:
public void TestOfMyMethod() {
// Setup
var moqService = new Mock<IMyService>();
IList<String> errors;
var model = new MyModel();
// This returns null, presumably becuase "errors"
// here does not refer to the same object as "errors" in MyMethod
moqService.Setup(t => t.DoSomething(ref errors, ref model, It.IsAny<SomeType>()).
Returns(new OtherType()));
}
UPDATE: Таким образом, изменяются ошибки с "ref" на "out". Поэтому кажется, что в реальной проблеме есть параметр ref, который вы не можете ввести.