public void Should_Take_In_Account_Calls_To_Abstract_Methods()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(AbstractTemplateClass).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
 }
 public void Should_Not_Take_In_Account_ToString_Methods()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(SimpleClassWithToString).GetCecilType());
     Assert.AreEqual(2, blocks.Count);
 }
 public void Should_Take_In_Account_Calls_Ignore_Empty_Methods()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(ClassWithCallsToEmptyMethods).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
 }
 public void Should_Not_Take_In_Account_Methods_From_Wrapped_Objects()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(SimpleClassWithDelegation).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
     Assert.AreEqual(3, blocks.ElementAt(0).Count);
 }
 public void Should_Not_Take_In_Account_References_To_Static_Fields()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(SimpleClassWithStaticField).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
     Assert.AreEqual(1, blocks.First().Count);
 }
        public void Should_Take_In_Account_Field_References()
        {
            var definition = AssemblyDefinition.ReadAssembly(@"testdata\external\Spring.Core.dll", new ReaderParameters { AssemblyResolver = AssemblyResolver.Resolver });

            var clientType = definition.MainModule.GetType("Spring.Collections.Generic", "ReadOnlyDictionary`2");
            var analyzer = new Lcom4Analyzer();
            var blocks = analyzer.FindLcomBlocks(clientType);
            Assert.AreEqual(12, blocks.Count);
        }
 public void Should_Find_One_Block_On_A_Simple_Class()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(SimpleClass).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
 }
 public void Should_Not_Fail_On_Empty_Interface()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(IEmpty).GetCecilType());
     Assert.AreEqual(0, blocks.Count);
 }
 public void Should_Not_Take_In_Account_Dispose_Methods()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(SimpleDisposableClass).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
 }
Пример #10
0
        public void Should_Ignore_Empty_Virtual_Methods()
        {
            var definition = AssemblyDefinition.ReadAssembly(@"testdata\external\Spring.Core.dll", new ReaderParameters { AssemblyResolver = AssemblyResolver.Resolver });

            var clientType = definition.MainModule.GetType("Spring.Expressions.Parser.antlr.debug", "ParserListenerBase");
            var analyzer = new Lcom4Analyzer();
            var blocks = analyzer.FindLcomBlocks(clientType);
            Assert.AreEqual(0, blocks.Count);
        }
Пример #11
0
 public void Should_Ignore_Simple_Accessors()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(ClassWithProperties).GetCecilType());
     Assert.AreEqual(0, blocks.Count);
 }
Пример #12
0
 public void Should_Ignore_Constructors()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(SimpleClassWithCtr).GetCecilType());
     Assert.AreEqual(2, blocks.Count);
 }
Пример #13
0
 public void Should_Ignore_Abstract_Methods()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(AbstractClass).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
 }
Пример #14
0
 public void Should_Find_Two_Blocks_On_A_Simple_Stateless_Class()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(SimpleCalculator).GetCecilType());
     Assert.AreEqual(2, blocks.Count);
 }
Пример #15
0
 public void Should_Take_In_Account_Calls_To_Simple_Accessors()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(ClassWithCallsToAccessors).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
 }
Пример #16
0
 public void Should_Not_Take_In_Account_Inherited_Methods()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(DerivedClass).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
     Assert.AreEqual(3, blocks.ElementAt(0).Count);
 }
Пример #17
0
 public void Should_Take_In_Account_Complex_Accessors()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(ClassWithComplexProperties).GetCecilType());
     Assert.AreEqual(2, blocks.Count);
 }
Пример #18
0
 public void Should_Not_Take_In_Account_Linq_Fields_In_Accessors()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(PropertyWithLinq).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
     // get, set and backing field
     Assert.AreEqual(3, blocks.First().Count);
 }
Пример #19
0
        public void Should_Take_In_Account_The_Ignorable_Field_Names()
        {
            var analyzer = new Lcom4Analyzer() { IgnorableFieldNames = new string[] {"Counter"} } ;

            var blocks = analyzer.FindLcomBlocks(typeof(SimpleClass).GetCecilType());
            Assert.AreEqual(2, blocks.Count);
        }
Пример #20
0
 public void Should_Find_One_Block_On_A_Class_With_Strong_Cohesion()
 {
     var analyzer = new Lcom4Analyzer();
     var blocks = analyzer.FindLcomBlocks(typeof(ClassWithManyMethodsAndStrongCohesion).GetCecilType());
     Assert.AreEqual(1, blocks.Count);
     Assert.AreEqual(5, blocks.ElementAt(0).Count);
 }