Example #1
0
        public void SutIsIMethod()
        {
            var method = new DelegatingMethod();
            var sut    = new MissingParametersSupplyingMethod(method);

            Assert.IsAssignableFrom <IMethod>(sut);
        }
Example #2
0
        public void MethodIsCorrect()
        {
            var expectedMethod = new DelegatingMethod();
            var sut            = new MissingParametersSupplyingMethod(expectedMethod);

            var result = sut.Method;

            Assert.Equal(expectedMethod, result);
        }
Example #3
0
        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);
        }
Example #4
0
        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));
        }
Example #5
0
        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);
        }