Beispiel #1
0
        public void ClassWithoutMethodsShouldReturnConstructor()
        {
            var engine = new Engine();
            var code = @" class C {} ";
            var asm = Compile("EmptyClass.dll", code);
            var type = asm.Modules.First().GetType("C");
            var dic = engine.GetMethods(type);

            Assert.AreEqual<int>(1, dic.Count());
        }
Beispiel #2
0
        public void ConverToMethodDictionaryShouldReturnTheSameAmountOfMethods()
        {
            var engine = new Engine();

            var testPath = typeof(CoolLibrary.Test).Assembly.Location;
            var asm = Mono.Cecil.AssemblyDefinition.ReadAssembly(testPath);

            var type = asm.MainModule.GetType("CoolLibrary.Test");
            Assert.IsNotNull(type);
            var methods = engine.GetMethods(type);
            Assert.AreEqual<int>(20, methods.Count);
        }
Beispiel #3
0
        public void GenericMethtodShouldNotBeConfusedWithNonGeneric()
        {
            var engine = new Engine();
            var code = @" class C {
                            public void SomePublicMethod(){}
                            public void SomePublicMethod<T>(){}
                          } ";
            var asm = Compile("EmptyClass.dll", code);
            var type = asm.Modules.First().GetType("C");
            var dic = engine.GetMethods(type);

            // 7 methods and one constructor
            Assert.AreEqual<int>(3, dic.Count());
        }
Beispiel #4
0
        public void MethodswithAllModifiersShouldInResultSet()
        {
            var engine = new Engine();
            var code = @" class C {
                            public void SomePublicMethod(){}
                            private void SomePrivateMethod(){}
                            protected void SomeProtectedMethod(){}
                            internal void SomeInternalMethod(){}
                            static void SomeStaticMethod(){}
                            public virtual void SomeVirtualMethod(){}

                            public override string ToString()
                            {
                                return base.ToString();
                            }
                          } ";
            var asm = Compile("EmptyClass.dll", code);
            var type = asm.Modules.First().GetType("C");

            var methods = engine.GetMethods(type);

            // 7 methods and one constructor
            Assert.AreEqual<int>(8, methods.Count());
        }
Beispiel #5
0
        public void InnerClassesShouldNotAffectMethodCount()
        {
            var engine = new Engine();
            var code = @"  class C
                {

                    public void SomePublicMethod() { }
                    private void SomePrivateMethod() { }
                    protected void SomeProtectedMethod() { }
                    internal void SomeInternalMethod() { }
                    static void SomeStaticMethod() { }
                    public virtual void SomeVirtualMethod() { }

                    public override string ToString()
                    {
                        return base.ToString();
                    }

                    class CInner1
                    {
                        public void SomePublicMethod() { }
                        private void SomePrivateMethod() { }
                        protected void SomeProtectedMethod() { }
                        internal void SomeInternalMethod() { }
                        static void SomeStaticMethod() { }
                        public virtual void SomeVirtualMethod() { }

                        public override string ToString()
                        {
                            return base.ToString();
                        }
                    }
                }";
            var asm = Compile("EmptyClass.dll", code);
            var outerType = asm.Modules.First().GetType("C");
            var outerMethods = engine.GetMethods(outerType);

            // 7 methods and one constructor
            Assert.AreEqual<int>(8, outerMethods.Count());
        }
Beispiel #6
0
        public void GettersAndSettersShoulBeInResultSet()
        {
            var engine = new Engine();
            var code = @" class C { int Prop {get; set;}} ";
            var asm = Compile("EmptyClass.dll", code);
            var type = asm.Modules.First().GetType("C");
            var dic = engine.GetMethods(type);

            // constructor, getter and setter
            Assert.AreEqual<int>(3, dic.Count());
        }