public void TestCreateAction2c() { string n = nameof(ExampleStruct1.Increment); Action2 inc = Accelerator.CreateAction2(typeof(ExampleStruct1).GetMethod(n, new[] { typeof(int) })); var unboxed = new ExampleStruct1(); unboxed.Increment(1); Assert.AreEqual(1, unboxed.Value); object boxed = unboxed; inc(boxed, 3); Assert.AreEqual(4, ((ExampleStruct1)boxed).Value); inc(boxed, 11); Assert.AreEqual(15, ((ExampleStruct1)boxed).Value); }
public void TestCreateAction1c() { string n = nameof(ExampleStruct1.Increment); Action1 inc = Accelerator.CreateAction1(typeof(ExampleStruct1).GetMethod(n, Type.EmptyTypes)); var unboxed = new ExampleStruct1(); unboxed.Increment(); Assert.AreEqual(1, unboxed.Value); object boxed = unboxed; inc(boxed); Assert.AreEqual(2, ((ExampleStruct1)boxed).Value); inc(boxed); inc(boxed); Assert.AreEqual(4, ((ExampleStruct1)boxed).Value); }