Exemplo n.º 1
0
 public void GetMethodInvalidParamsTest()
 {
     Assert.Throws <ArgumentException>(() => KUtility.GetMethod(typeof(UtilityTests),
                                                                BindingFlags.Instance | BindingFlags.Public,
                                                                nameof(GetMethodTest),
                                                                Array.Empty <Type>(),
                                                                new object[] { this }));
 }
Exemplo n.º 2
0
 public void GetMethodInvalidGenericsTest()
 {
     Assert.Throws <ArgumentException>(() => KUtility.GetMethod(typeof(UtilityTests),
                                                                BindingFlags.Instance | BindingFlags.Public,
                                                                nameof(GetMethodTest),
                                                                new[] { typeof(KUtility) },
                                                                Array.Empty <object>()));
 }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }