示例#1
0
        public void Create_IfMultipleReferenceParameters_RoundtripsArguments(bool isInstance)
        {
            // Arrange
            MethodInfo method           = GetMethodInfo(isInstance, "TestByRefIntStringObjectArray");
            int        expectedInitialA = 1;
            string     expectedInitialB = "B";

            object[] expectedInitialC = new object[] { new object() };
            int      expectedFinalA   = 2;
            string   expectedFinalB   = "b";

            object[] expectedFinalC = new object[] { new object(), default(int), String.Empty };

            // Act
            IMethodInvoker <MethodInvokerFactoryTests> invoker =
                MethodInvokerFactory.Create <MethodInvokerFactoryTests>(method);

            // Assert
            Assert.NotNull(invoker);
            bool        callbackCalled = false;
            ByRefAction callback       = delegate(ref int a, ref string b, ref object[] c)
            {
                callbackCalled = true;
                Assert.Equal(expectedInitialA, a);
                Assert.Same(expectedInitialB, b);
                Assert.Same(expectedInitialC, c);
                a = expectedFinalA;
                b = expectedFinalB;
                c = expectedFinalC;
            };
            MethodInvokerFactoryTests instance = GetInstance(isInstance);

            object[] arguments = new object[] { expectedInitialA, expectedInitialB, expectedInitialC, callback };
            invoker.InvokeAsync(instance, arguments).GetAwaiter().GetResult();
            Assert.True(callbackCalled);
            Assert.Equal(expectedFinalA, arguments[0]);
            Assert.Same(expectedFinalB, arguments[1]);
            Assert.Same(expectedFinalC, arguments[2]);
        }
示例#2
0
 private void InstanceTestByRefIntStringObjectArray(ref int a, ref string b, ref object[] c,
                                                    ByRefAction callback)
 {
     callback.Invoke(ref a, ref b, ref c);
 }
示例#3
0
 public void ForEachFilteredItem <TData>(
     ByRefAction <T, TData> action, in TData data)
 private void InstanceTestByRefIntStringObjectArray(ref int a, ref string b, ref object[] c,
     ByRefAction callback)
 {
     callback.Invoke(ref a, ref b, ref c);
 }