Пример #1
0
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            var hash = 1721;

            hash = (hash * 5701) + Function.GetHashCode();
            hash = (hash * 5701) + ParametersCount.GetHashCode();

            return(hash);
        }
Пример #2
0
        public void MethodWith_LimitParameters_HasNotAnalyzerError()
        {
            var methodParameterRule = QualityRules.MethodParametersCount;
            var maximumParameters   = new Metric().MaximumNumberOfMethodParameters;

            var methodName       = "newMethod";
            var methodParameters = MockParameter.ParameterDeclarations(maximumParameters - 1);
            var method           = MockMethod.Method(methodName, methodParameters);

            var parameterAnalyzer = new ParametersCount(TestBootStrapped.GetInstanceOfIMetric());

            parameterAnalyzer.Analyze(method);
            var analyzeResult = parameterAnalyzer.GetResult();

            var hasAcceptableNumberOfParameters = !analyzeResult.Any(a => a.ViolatedRule.Equals(methodParameterRule));

            Assert.IsTrue(hasAcceptableNumberOfParameters);
        }
Пример #3
0
        public override string ToString()
        {
            if (IsOperator)
            {
                StringBuilder a = new StringBuilder(25);

                if ((_Associativity & OPERATOR_FX) != 0)
                {
                    a.Append("FX+");
                }
                if ((_Associativity & OPERATOR_FY) != 0)
                {
                    a.Append("FY+");
                }
                if ((_Associativity & OPERATOR_XFY) != 0)
                {
                    a.Append("XFY+");
                }
                if ((_Associativity & OPERATOR_YFX) != 0)
                {
                    a.Append("YFX+");
                }
                if ((_Associativity & OPERATOR_XF) != 0)
                {
                    a.Append("XF+");
                }
                if ((_Associativity & OPERATOR_YF) != 0)
                {
                    a.Append("YF+");
                }
                a.Length--;

                return("[" + Name + ", Precedence=" + Precedence.ToString() + ", Associativity=" + a + ", Flags=" + Convert.ToString(_Flags, 2) + "]");
            }

            return("[" + Name + ", ParamCount=" + ParametersCount.ToString() + ", Flags=" + Convert.ToString(_Flags, 2) + "]");
        }