public void Create_IfInOutByRefMethodReturnsTask_RoundtripsArguments(bool isInstance) { // Arrange MethodInfo method = GetMethodInfo(isInstance, "TestInOutByRefReturnTask"); int expectedA = 1; string expectedInitialB = "B"; string expectedFinalB = "b"; object[] expectedC = new object[] { new object(), default(int), String.Empty }; // Act IMethodInvoker <MethodInvokerFactoryTests> invoker = MethodInvokerFactory.Create <MethodInvokerFactoryTests>(method); // Assert Assert.NotNull(invoker); bool callbackCalled = false; InOutRefTaskFunc callback = delegate(int a, ref string b, out object[] c) { callbackCalled = true; Assert.Equal(expectedA, a); Assert.Same(expectedInitialB, b); b = expectedFinalB; c = expectedC; return(Task.FromResult(0)); }; MethodInvokerFactoryTests instance = GetInstance(isInstance); object[] arguments = new object[] { expectedA, expectedInitialB, null, callback }; invoker.InvokeAsync(instance, arguments).GetAwaiter().GetResult(); Assert.True(callbackCalled); Assert.Same(expectedFinalB, arguments[1]); Assert.Same(expectedC, arguments[2]); }
private Task InstanceTestInOutByRefReturnTask(int a, ref string b, out object[] c, InOutRefTaskFunc callback) { return(callback.Invoke(a, ref b, out c)); }
private Task InstanceTestInOutByRefReturnTask(int a, ref string b, out object[] c, InOutRefTaskFunc callback) { return callback.Invoke(a, ref b, out c); }