public void GetAction_ShouldReturnInvocable(TestCaseData <MethodInfo> testCase) { var factory = new DynamicMethodFactory(); var methodRequest = DynamicMethodRequest.MakeRequest(testCase.Method); var method = factory.GetAction(methodRequest); Assert.That(method, Is.Not.Null); var methodArgs = TestCaseHelper.GetArgs(testCase.Args, testCase.Instance); method.Invoker.DynamicInvoke(methodArgs); }
public void GetFunction_ShouldReturnInvocable(TestCaseData <MethodInfo> testCase) { var factory = new DynamicMethodFactory(); var methodRequest = DynamicMethodRequest.MakeRequest(testCase.Method); var method = factory.GetFunction <int>(methodRequest); Assert.That(method, Is.Not.Null); var methodArgs = TestCaseHelper.GetArgs(testCase.Args, testCase.Instance); var result = (int)method.Invoker.DynamicInvoke(methodArgs); Assert.That(result, Is.EqualTo(testCase.ExpectedResult)); }
public void GenerateField_ShouldBeBidirectional(TestCaseData <FieldInfo> testCase) { var factory = new DynamicMethodFactory(); var expectedResult = testCase.Args.Last(); var setRequest = DynamicMethodRequest.MakeSetterRequest(testCase.Method); var setMethod = factory.GetAction(setRequest); var setArgs = TestCaseHelper.GetArgs(testCase.Args, testCase.Instance); setMethod.Invoke(setArgs); var getRequest = DynamicMethodRequest.MakeGetterRequest(testCase.Method); var getMethod = factory.GetFunction <int>(getRequest); var getArgs = TestCaseHelper.GetArgs(null, testCase.Instance); var result = getMethod.Invoke(getArgs); Assert.That(result, Is.EqualTo(expectedResult)); }