Exemplo n.º 1
0
 public void CrapLoadCalculatedCorrectly()
 {
     CrapDataEntry target1 = new CrapDataEntry("SomeClass", "SomeMethod", 40.51, 27, 9);
     Assert.AreEqual(9.2666666666666675d, target1.CalculateCrapLoad());
 }
Exemplo n.º 2
0
 public void CrapLoadCalculatedCorrectlyWhenCoverageIsZero()
 {
     CrapDataEntry target1 = new CrapDataEntry("SomeClass", "SomeMethod", 40.51, 0, 9);
     Assert.AreEqual(9.5999999999999996d, target1.CalculateCrapLoad());
 }
        private XmlElement CreateMethodElement(XmlDocument xmlDoc,CrapDataEntry method)
        {
            var methodElement = xmlDoc.CreateElement("method");

            var package = xmlDoc.CreateElement("package");
            var packValue = xmlDoc.CreateTextNode(method.Method.TypeName);
            package.AppendChild(packValue);
            methodElement.AppendChild(package);

            var className = xmlDoc.CreateElement("className");
            var classNameValue = xmlDoc.CreateTextNode(method.Method.TypeName);
            className.AppendChild(classNameValue);
            methodElement.AppendChild(className);

            var methodName = xmlDoc.CreateElement("methodName");
            var methodNameValue = xmlDoc.CreateTextNode(method.Method.MethodName);
            methodName.AppendChild(methodNameValue);
            methodElement.AppendChild(methodName);

            var methodSignature = xmlDoc.CreateElement("methodSignature");
            var methodSignatureValue = xmlDoc.CreateTextNode("()");
            methodSignature.AppendChild(methodSignatureValue);
            methodElement.AppendChild(methodSignature);

            var fullMethod = xmlDoc.CreateElement("fullMethod");
            var fullMethodValue = xmlDoc.CreateTextNode(string.Format("{0}.{1}",method.Method.TypeName,method.Method.MethodName));
            fullMethod.AppendChild(fullMethodValue);
            methodElement.AppendChild(fullMethod);

            var crap = xmlDoc.CreateElement("crap");
            var crapValue = xmlDoc.CreateTextNode(method.Crap.ToString());
            crap.AppendChild(crapValue);
            methodElement.AppendChild(crap);

            var complexity= xmlDoc.CreateElement("complexity");
            var complexityValue = xmlDoc.CreateTextNode(method.CC.ToString());
            complexity.AppendChild(complexityValue);
            methodElement.AppendChild(complexity);

            var coverage = xmlDoc.CreateElement("coverage");
            var coverageValue = xmlDoc.CreateTextNode(method.Coverage.ToString());
            coverage.AppendChild(coverageValue);
            methodElement.AppendChild(coverage);

            var crapLoad = xmlDoc.CreateElement("crapLoad");
            var crapLoadValue = xmlDoc.CreateTextNode(method.CalculateCrapLoad().ToString("0"));
            crapLoad.AppendChild(crapLoadValue);
            methodElement.AppendChild(crapLoad);

            return methodElement;
        }