public void MethodsWithMoreThanTenStatementsBreakRule(string methodName, int expectedProblemCount)
        {
            var rule = new LongMethodRule();

            rule.Check(AssemblyReader.GetMethodByName(typeof(Bar), methodName));
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
        public void MethodsWithMoreThanThreeParamsBreakRule(string methodName, int expectedProblemCount)
        {
            var rule = new LongParamListRule();

            rule.Check(AssemblyReader.GetMethodByName(typeof(Foo), methodName));
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
Esempio n. 3
0
        public void MethodsWithMoreThanThreeBranchesBreakRule(string methodName, int expectedProblemCount)
        {
            var rule = new MethodComplexityRule();

            rule.Check(AssemblyReader.GetMethodByName(typeof(ClassD), methodName));
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
        public void CallsToBaseClassMethodsDontCount(string typeName, int expectedProblemCount)
        {
            var rule = new ClientInterfaceRule();

            rule.Check(AssemblyReader.GetType(typeName));
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
Esempio n. 5
0
        public void ClassesWithMoreThanThreeCollaboratorsBreakRule(string typeName, int expectedProblemCount)
        {
            var rule = new MaxCollaboratorsRule();

            rule.Check(AssemblyReader.GetType(typeName));
            Assert.That(rule.Problems.Count, Is.EqualTo(expectedProblemCount));
        }
        public void FactoryOrBuilderMethodsDontCount(string methodName, int expectedProblemCount)
        {
            var rule = new MethodCallRule();

            rule.Check(AssemblyReader.GetMethodByName(typeof(ClassF), methodName));
            Assert.That(rule.Problems.Count, Is.EqualTo(expectedProblemCount));
        }
        public void InterfacesWithMoreMethodsThatClientUsesBreakRule(string typeName, int expectedProblemCount)
        {
            var rule = new ClientInterfaceRule();

            rule.Check(AssemblyReader.GetType(typeName));
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
        public void CannotInvokeConcreteMethods(string methodName, int expectedProblemCount)
        {
            var rule = new MethodCallRule();

            rule.Check(AssemblyReader.GetMethodByName(typeof(ClassF), methodName));
            Assert.That(rule.Problems.Count, Is.EqualTo(expectedProblemCount));
        }
        public void MethodsCantUseNewOnProjectClasses(string methodName, int expectedProblemCount)
        {
            var rule = new ObjectCreationRule();

            rule.Check(AssemblyReader.GetMethodByName(typeof(ClassE), methodName));
            Assert.That(rule.Problems.Count, Is.EqualTo(expectedProblemCount));
        }
Esempio n. 10
0
        public void TypesWithMoreThanTenMethodsOrPropertiesBreakRule(string typeName, int expectedProblemCount)
        {
            var rule = new LargeClassRule();

            rule.Check(AssemblyReader.GetType(typeName));
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
        public void MethodsThatMakeMultipleCallsToCollaboratorsHaveFeatureEnvy(string methodName,
                                                                               int expectedProblemCount)
        {
            var rule = new FeatureEnvyRule();

            rule.Check(AssemblyReader.GetMethodByName(typeof(Client), methodName));
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
        private void CheckIfCollaboratorFound(string typeName, string collaboratorTypeName)
        {
            var collaboratorCount = new CollaboratorCount();
            var type = AssemblyReader.GetType(typeName);

            Assert.That(collaboratorCount.GetCollaboratorsFor(type)
                        .ToList()
                        .Exists(c => c.Name.Name == collaboratorTypeName));
        }
        public void DoesntIncludeBaseClasses()
        {
            var collaboratorCount = new CollaboratorCount();
            var type = AssemblyReader.GetType("ThisClass");

            Assert.That(!collaboratorCount.GetCollaboratorsFor(type)
                        .ToList()
                        .Exists(c => c.Name.Name == "BaseClass"));
        }
Esempio n. 14
0
        public void MethodsWithBooleanParametersBreakRule(string methodName, int expectedProblemCount)
        {
            var rule   = new BooleanParameterRule();
            var method = AssemblyReader.GetMethodByName(typeof(ClassC), methodName);
            var param  = method.Parameters[0];

            rule.Check(param);
            Assert.AreEqual(expectedProblemCount, rule.Problems.Count);
        }
        public void IdentifiersLongerThanTwentyCharsBreakRule(string identifier, int expectedProblemCount)
        {
            var rule   = new IdentifierLengthRule();
            var module = AssemblyReader.GetAssembly();

            rule.Check(module);
            Assert.That(rule.Problems.Count(p => p.Resolution.ToString().Contains(identifier)),
                        Is.EqualTo(expectedProblemCount));
        }