Beispiel #1
0
 public void ShouldThrowArgumentExceptionForObjectCreationInBody()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var methodInfo = MethodInfoUtil.GetMethodInfo <DummyObject.Factory>(
             factory => new DummyObject.Factory());
     });
 }
Beispiel #2
0
        public void ShouldReturnMethodInfoForStaticMethod()
        {
            var methodInfo = MethodInfoUtil.GetMethodInfo(() => StaticMethod());

            Assert.NotNull(methodInfo);
            Assert.AreEqual("StaticMethod", methodInfo.Name);
            Assert.AreEqual(typeof(void), methodInfo.ReturnType);
        }
Beispiel #3
0
        public void ShouldReturnMethodInfoForFunctionInBodyNoArgument()
        {
            int x          = 5;
            var methodInfo = MethodInfoUtil.GetMethodInfo(() => x.ToString());

            Assert.NotNull(methodInfo);
            Assert.AreEqual("ToString", methodInfo.Name);
            Assert.AreEqual(typeof(string), methodInfo.ReturnType);
        }
Beispiel #4
0
        public void ShouldReturnMethodInfoForFunctionInBody()
        {
            var methodInfo = MethodInfoUtil.GetMethodInfo <int>(
                x => x.ToString());

            Assert.NotNull(methodInfo);
            Assert.AreEqual("ToString", methodInfo.Name);
            Assert.AreEqual(typeof(string), methodInfo.ReturnType);
        }