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

            return((R)MethodInvoke.StaticMethod <T>(methodName, parameters).Value);
        }
Exemplo n.º 2
0
        public void ToCall(
            string methodName,
            object first,
            params object[] rest)
        {
            var parameters = MethodInvoke.NormalizeParameters(first, rest);

            MethodInvoke.StaticMethod <T>(methodName, parameters);
        }
Exemplo n.º 3
0
        public void CanCallStaticMethodWithoutArgsAndWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticVoidMethodWithoutArgs", new object[0]);

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
        }
Exemplo n.º 4
0
        public void CanCallStaticMethodWithoutArgsButWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticStringMethodWithoutArgs", new object[0]);

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("successStaticStringMethodWithoutArgs", result.Value);
        }
Exemplo n.º 5
0
        public void CanCallStaticMethodWithArgsAndWithResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticStringMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.True(result.HasResult);
            Assert.Equal("successStaticStringMethodWithArgs", result.Value);
            trackable.Received(1).Touch();
        }
Exemplo n.º 6
0
        public void CanCallStaticMethodWithArgsButWithoutResult()
        {
            // Arrange
            // Act
            var result = MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>("StaticVoidMethodWithArgs", new object[] { trackable });

            // Assert
            Assert.False(result.HasResult);
            Assert.Null(result.Value);
            trackable.Received(1).Touch();
        }
Exemplo n.º 7
0
        public void CallingStaticMethodWithNullForValueTypeParameterThrowsException()
        {
            // Arrange
            // Act
            var caught = Assert.Throws <InvalidOperationException>(() =>
                                                                   MethodInvoke.StaticMethod <ClassWithPrivateMethods>(
                                                                       "StaticVoidMethodWhichIsNotOkayWhenArgIsNull",
                                                                       new object[] { null }));

            // Assert
            Assert.Equal("Didn't find a method mathing passed parameters.", caught.Message);
        }
Exemplo n.º 8
0
        public void CanCallStaticMethodWithNullArgs()
        {
            // Arrange
            // Act
            var result = (string)MethodInvoke
                         .StaticMethod <ClassWithPrivateMethods>(
                "StaticStringMethodWhichIsOkayWhenArgIsNull",
                new object[] { null })
                         .Value;

            // Assert
            Assert.Equal(result, "Arg is null");
        }
Exemplo n.º 9
0
 public R ToCall <R>(
     string methodName)
 {
     return((R)MethodInvoke.StaticMethod <T>(methodName, new object[0]).Value);
 }
Exemplo n.º 10
0
 public void ToCall(string methodName)
 {
     MethodInvoke.StaticMethod <T>(methodName, new object[0]);
 }