public void GetPriorityTest_CorrectEqualityPriority(ArithmeticSign signPriority, ArithmeticSign signPriorityOther)
        {
            int actualPriority      = signPriority.GetPriority();
            int actualPriorityOther = signPriorityOther.GetPriority();

            Assert.IsTrue(actualPriority == actualPriorityOther, $"Sign priority: {signPriority} == {signPriorityOther}");
        }
        public void GetPriorityTest_CorrectJuniorPriority(ArithmeticSign signLoverPriority, ArithmeticSign signHigherPriority)
        {
            int actualLoverPriority  = signLoverPriority.GetPriority();
            int actualHigherPriority = signHigherPriority.GetPriority();

            Assert.IsTrue(actualLoverPriority < actualHigherPriority, $"Sign priority: {signLoverPriority} < {actualHigherPriority}");
        }
Esempio n. 3
0
        private static ArithmeticSignAttribute GetArithmeticSignAttribute(this ArithmeticSign enumElement)
        {
            Type type = enumElement.GetType();

            MemberInfo[] memInfo = type.GetMember(enumElement.ToString());

            if (memInfo.Length > 0)
            {
                object[] attrs = memInfo[0].GetCustomAttributes(typeof(ArithmeticSignAttribute), false);

                if (attrs.Length > 0)
                {
                    return(attrs[0] as ArithmeticSignAttribute);
                }
            }

            throw new NullReferenceException("The sign has no ArithmeticSign attribute");
        }
        public void GetArithmeticSignTypeTest_CorrectArithmeticSign(char symbolSign, ArithmeticSign expectedSign)
        {
            var actualSign = ArithmeticSignHelpers.GetArithmeticSignType(symbolSign);

            Assert.AreEqual(expectedSign, actualSign, $"Sign: {actualSign} != {expectedSign}");
        }
        public void EqualsSignTest_CorrectValue(ArithmeticSign sign, char symbolSign, bool expectedValue)
        {
            bool actualValue = sign.EqualsSign(symbolSign);

            Assert.AreEqual(expectedValue, actualValue, $"Sign {sign} != {symbolSign}");
        }
        public void GetSignTest_CorrectSign(ArithmeticSign sign, char expectedSign)
        {
            char actualSign = sign.GetSign();

            Assert.AreEqual(expectedSign, actualSign, $"Invalid sign received: {expectedSign}");
        }
Esempio n. 7
0
 public NestedExpression(int index, IList <ITerm> expression, ArithmeticSign sign = ArithmeticSign.Sum)
 {
     this.Index      = index;
     this.Sign       = sign;
     this.Expression = expression;
 }
Esempio n. 8
0
 public ExpressionTerm(ArithmeticSign sign)
 {
     this.Sign       = sign;
     this.Expression = new List <ITerm>();
 }
Esempio n. 9
0
 public ExpressionTerm(ArithmeticSign sign, IList <ITerm> expression)
 {
     this.Sign       = sign;
     this.Expression = expression;
 }
Esempio n. 10
0
        public static char GetSign(this ArithmeticSign enumElement)
        {
            ArithmeticSignAttribute arithmeticSign = GetArithmeticSignAttribute(enumElement);

            return(arithmeticSign.Sign);
        }
Esempio n. 11
0
 public static bool EqualsSign(this ArithmeticSign enumElement, char symbol)
 {
     return(symbol.Equals(enumElement.GetSign()));
 }
Esempio n. 12
0
        public static int GetPriority(this ArithmeticSign enumElement)
        {
            ArithmeticSignAttribute arithmeticSign = GetArithmeticSignAttribute(enumElement);

            return(arithmeticSign.Priority);
        }
Esempio n. 13
0
 public NumberTerm(ArithmeticSign sign, decimal digit)
 {
     this.Sign  = sign;
     this.Digit = digit;
 }