public void SutIsIMethod() { var method = new DelegatingMethod(); var sut = new MissingParametersSupplyingMethod(method); Assert.IsAssignableFrom <IMethod>(sut); }
public void MethodIsCorrect() { var expectedMethod = new DelegatingMethod(); var sut = new MissingParametersSupplyingMethod(expectedMethod); var result = sut.Method; Assert.Equal(expectedMethod, result); }
public void InvokeReturnsCorrectResult(Type targetType, string methodName, object[] arguments, object expected) { var method = new DelegatingMethod(); var methodInfo = targetType.GetMethod(methodName); method.OnParameters = methodInfo.GetParameters; method.OnInvoke = args => methodInfo.Invoke(null, args.ToArray()); var sut = new MissingParametersSupplyingMethod(method); var result = sut.Invoke(arguments); Assert.Equal(expected, result); }
public void ParametersIsCorrect() { Action <int, double> dummy = (i, d) => { }; var expectedParameters = dummy.GetMethodInfo().GetParameters(); var method = new DelegatingMethod { OnParameters = () => expectedParameters }; var sut = new MissingParametersSupplyingMethod(method); var result = sut.Parameters; Assert.True(expectedParameters.SequenceEqual(result)); }
public void InvokeWithCorrectArgumentsReturnsCorrectResult() { var arguments = new[] { new object(), new object() }; var expected = new object(); Action <object, object> dummy = (o1, o2) => { }; var method = new DelegatingMethod(); method.OnParameters = () => dummy.GetMethodInfo().GetParameters(); method.OnInvoke = args => arguments.SequenceEqual(args) ? expected : null; var sut = new MissingParametersSupplyingMethod(method); var result = sut.Invoke(arguments); Assert.Equal(expected, result); }