Telerik JustMock
public
class
ClassUsingRefReturns
{
private
static
int
[] array = { 1, 2, 3, 4 };
public
ref
int
GetRefReturnInstanceWithArgs(
ref
int
p)
{
ref
int
local =
ref
array[0];
local += p;
return
ref
local;
}
}
...
[TestMethod]
public
void
MockRefReturnInstanceMethodWithArgs()
{
var localRef = LocalRef.WithValue(12);
// Arrange
var sut = Mock.Create<ClassUsingRefReturns>();
Mock.Arrange(sut, s => s.GetRefReturnInstanceWithArgs(
ref
Arg.Ref(Arg.AnyInt).Value)))
.Returns(localRef.Handle)
.OccursOnce();
// Act
int
param = 10;
ref
int
res =
ref
sut.GetRefReturnInstance(
ref
param);
// Assert
Mock.Assert(sut);
Assert.AreEqual(localRef.Ref, res);
}