public void ShimmedMethod_Generates_From_Instance_Call_With_Reference_Type_Param_And_Returns_Reference_Type() { var a = new InstanceMethodsTestClass(); var shimmedMethod = new ShimmedMethod <List <int> >(typeof(InstanceMethodsTestClass).GetMethod("MethodWithReferenceTypeParamsAndReturn")); Assert.IsNotNull(shimmedMethod); Assert.IsNotNull(shimmedMethod.Method); Assert.IsNotNull(shimmedMethod.Shim); var beforeDateTime = DateTime.Now; List <int> value = null; PoseContext.Isolate(() => { value = a.MethodWithReferenceTypeParamsAndReturn(new List <int> { 3, 2, 1 }); }, new[] { shimmedMethod.Shim }); Assert.IsNotNull(value); Assert.AreEqual(1, shimmedMethod.CallResults.Count); var callResult = shimmedMethod.CallResults.First(); Assert.IsNotNull(callResult.Parameters); var afterDateTime = DateTime.Now; Assert.IsNotNull(callResult.CalledAt); Assert.IsTrue(beforeDateTime < callResult.CalledAt && callResult.CalledAt < afterDateTime); // first parameter should be instance var instanceParam = callResult.Parameters[0] as InstanceMethodsTestClass; Assert.IsNotNull(instanceParam); Assert.AreEqual(a.InstanceGuid, instanceParam.InstanceGuid); Assert.IsTrue(((List <int>)callResult.Parameters[1]).SequenceEqual(new List <int> { 3, 2, 1 })); }
public List <int> MethodWithReferenceTypeParamsAndReturn(List <int> args) { var inst = new InstanceMethodsTestClass(); return(inst.MethodWithReferenceTypeParamsAndReturn(args)); }