예제 #1
0
        public void Calculates_lines_of_code_for_CSharp_class_elements()
        {
            CodeModelFactory factory = new CodeModelFactory();

            List <CaDETClass> classes = factory.CreateProject(_testDataFactory.GetDoctorClassText()).Classes;

            var doctorClass = classes.First();

            doctorClass.Metrics[CaDETMetric.CLOC].ShouldBe(22);
            doctorClass.FindMember("Email").Metrics[CaDETMetric.MLOC].ShouldBe(1);
            doctorClass.FindMember("IsAvailable").Metrics[CaDETMetric.MLOC].ShouldBe(8);
        }
예제 #2
0
        public void Compiles_CSharp_class_with_appropriate_fields_and_methods()
        {
            CodeModelFactory factory = new CodeModelFactory();

            List <CaDETClass> classes = factory.CreateProject(_testDataFactory.GetDoctorClassText()).Classes;

            classes.ShouldHaveSingleItem();
            var doctorClass = classes.First();

            doctorClass.Members.ShouldContain(method =>
                                              method.Type.Equals(CaDETMemberType.Property) && method.Name.Equals("Email"));
            doctorClass.Members.ShouldContain(method => method.Type.Equals(CaDETMemberType.Constructor));
            doctorClass.Members.ShouldContain(method =>
                                              method.Type.Equals(CaDETMemberType.Method) && method.Name.Equals("IsAvailable"));
            doctorClass.Members.First().Parent.SourceCode.ShouldBe(doctorClass.SourceCode);
            doctorClass.FindMember("Email").Modifiers.First().Value.ShouldBe(CaDETModifierValue.Public);
            doctorClass.FindMember("IsAvailable").Modifiers.First().Value.ShouldBe(CaDETModifierValue.Internal);
        }