Ejemplo n.º 1
0
        public R ToCall <R>(
            string methodName,
            object first,
            params object[] rest)
        {
            var parameters = MethodInvoke.NormalizeParameters(first, rest);

            return((R)MethodInvoke.InstanceMethod(@object, methodName, parameters).Value);
        }
Ejemplo n.º 2
0
        public void ToCall(
            string methodName,
            object first,
            params object[] rest)
        {
            var parameters = MethodInvoke.NormalizeParameters(first, rest);

            MethodInvoke.InstanceMethod(@object, methodName, parameters);
        }
Ejemplo n.º 3
0
        public void CanCallInstanceMethodWithoutArgsButWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceStringMethodWithoutArgs", new object[0]);

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("successInstanceStringMethodWithoutArgs", result.Value);
        }
Ejemplo n.º 4
0
        public void CanCallInstanceMethodWithoutArgsAndWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceVoidMethodWithoutArgs", new object[0]);

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
        }
Ejemplo n.º 5
0
        public void CanCallInstanceMethodWithArgsAndWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceStringMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("success", result.Value);
            trackable.Received(1).Touch();
        }
Ejemplo n.º 6
0
        public void CanCallInstanceMethodWithArgsButWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke.InstanceMethod(target, "InstanceVoidMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
            trackable.Received(1).Touch();
        }
Ejemplo n.º 7
0
        public void CanCallMethodWithNullArgs()
        {
            // Arrange
            // Act
            var result = (string)MethodInvoke
                         .InstanceMethod(target, "InstanceStringMethodWhichIsOkayWhenArgIsNull", new object[] { null })
                         .Value;

            // Assert
            Assert.Equal(result, "Arg is null");
        }
Ejemplo n.º 8
0
        public void CallingMethodWithNullForValueTypeParameterThrowsException()
        {
            // Arrange
            // Act
            var caught = Assert.Throws <InvalidOperationException>(() =>
                                                                   MethodInvoke.InstanceMethod(
                                                                       target,
                                                                       "InstanceVoidMethodWhichIsNotOkayWhenArgIsNull",
                                                                       new object[] { null }));

            // Assert
            Assert.Equal("Didn't find a method mathing passed parameters.", caught.Message);
        }
Ejemplo n.º 9
0
 public R ToCall <R>(string methodName)
 {
     return((R)MethodInvoke.InstanceMethod(@object, methodName, new object[0]).Value);
 }
Ejemplo n.º 10
0
 public void ToCall(string methodName)
 {
     MethodInvoke.InstanceMethod(@object, methodName, new object[0]);
 }