public void Bind_ZeroParamsVirtualInstanceNonVoidMethod([Values] bool emptyPartialApplyBefore, [Values] bool emptyPartialApplyAfter) { MethodClosureExtensionsFixture.Do(fixture => { var c = new TestClassZeroParams(13); var method = typeof(TestClassZeroParams).GetMethod(nameof(TestClassZeroParams.ZeroParamsVirtualInstanceNonVoidMethod)); if (emptyPartialApplyBefore) { method = method.PartialApply(); } method = method.Bind(c); if (emptyPartialApplyAfter) { method = method.PartialApply(); } var closureMethod = (ClosureMethod)method; Assert.AreSame(c, closureMethod.FixedThisArgument); CollectionAssert.AreEqual(new object[0], closureMethod.FixedArguments); var returnValue = method.Invoke(null, new object[0]) as TestClass; Assert.AreSame(c, returnValue); returnValue = method.CreateDelegate <Func <TestClass> >()(); Assert.AreSame(c, returnValue); fixture.ExpectedLogs = new[] { "ZeroParamsVirtualInstanceNonVoidMethod: 13", "ZeroParamsVirtualInstanceNonVoidMethod: 13", }; }); }
public void PartialApply_ZeroParamsVirtualInstanceNonVoidMethod([Values] bool additionalEmptyPartialApply) { MethodClosureExtensionsFixture.Do(fixture => { var c = new TestClassZeroParams(9); var method = typeof(TestClassZeroParams).GetMethod(nameof(TestClassZeroParams.ZeroParamsVirtualInstanceNonVoidMethod)); method = method.PartialApply(); if (additionalEmptyPartialApply) { method = method.PartialApply(); } var closureMethod = (ClosureMethod)method; Assert.IsNull(closureMethod.FixedThisArgument); CollectionAssert.AreEqual(new object[0], closureMethod.FixedArguments); var returnValue = method.Invoke(c, new object[0]) as TestClass; Assert.AreSame(c, returnValue); returnValue = method.CreateDelegate <Func <TestClass> >(c)(); Assert.AreSame(c, returnValue); fixture.ExpectedLogs = new[] { "ZeroParamsVirtualInstanceNonVoidMethod: 9", "ZeroParamsVirtualInstanceNonVoidMethod: 9", }; }); }