示例#1
0
 public void GetMethodInvalidParamsTest()
 {
     Assert.Throws <ArgumentException>(() => KUtility.GetMethod(typeof(UtilityTests),
                                                                BindingFlags.Instance | BindingFlags.Public,
                                                                nameof(GetMethodTest),
                                                                Array.Empty <Type>(),
                                                                new object[] { this }));
 }
示例#2
0
 public void GetMethodInvalidGenericsTest()
 {
     Assert.Throws <ArgumentException>(() => KUtility.GetMethod(typeof(UtilityTests),
                                                                BindingFlags.Instance | BindingFlags.Public,
                                                                nameof(GetMethodTest),
                                                                new[] { typeof(KUtility) },
                                                                Array.Empty <object>()));
 }
示例#3
0
        public void GetPropertyName_Test()
        {
            Expression <Func <Show, int> >    member     = x => x.ID;
            Expression <Func <Show, object> > memberCast = x => x.ID;

            Assert.Equal("ID", KUtility.GetPropertyName(member));
            Assert.Equal("ID", KUtility.GetPropertyName(memberCast));
            Assert.Throws <ArgumentException>(() => KUtility.GetPropertyName(null));
        }
示例#4
0
        public void GetMethodTest2()
        {
            MethodInfo method = KUtility.GetMethod(typeof(Merger),
                                                   BindingFlags.Static | BindingFlags.Public,
                                                   nameof(Merger.MergeLists),
                                                   new[] { typeof(string) },
                                                   new object[] { "string", "string2", null });

            Assert.Equal(nameof(Merger.MergeLists), method.Name);
        }
示例#5
0
        public void GetMethodTest()
        {
            MethodInfo method = KUtility.GetMethod(typeof(UtilityTests),
                                                   BindingFlags.Instance | BindingFlags.Public,
                                                   nameof(GetMethodTest),
                                                   Array.Empty <Type>(),
                                                   Array.Empty <object>());

            Assert.Equal(MethodBase.GetCurrentMethod(), method);
        }
示例#6
0
        public void IsPropertyExpression_Tests()
        {
            Expression <Func <Show, int> >    member     = x => x.ID;
            Expression <Func <Show, object> > memberCast = x => x.ID;

            Assert.False(KUtility.IsPropertyExpression(null));
            Assert.True(KUtility.IsPropertyExpression(member));
            Assert.True(KUtility.IsPropertyExpression(memberCast));

            Expression <Func <Show, object> > call = x => x.GetID("test");

            Assert.False(KUtility.IsPropertyExpression(call));
        }