Пример #1
0
        public void Test_Arith_2()
        {
            //1+2=4
            var lhs = new Term(Expression.Add, new List <object>()
            {
                1, 2
            });
            var  equation = new Equation(lhs, 4);
            bool result   = equation.ContainsVar();

            Assert.False(result);
            Assert.True(equation.ToString().Equals("1+2=4"));

            object obj = equation.Eval();

            Assert.NotNull(obj);
            var satisfied = obj as bool?;

            Assert.NotNull(satisfied);
            Assert.False(satisfied.Value);
            Assert.True(equation.CachedEntities.Count == 1);
            var cachedEq = equation.CachedEntities.ToList()[0] as Equation;

            Assert.NotNull(cachedEq);

            Assert.True(cachedEq.ToString().Equals("3=4"));
            Assert.True(cachedEq.Traces.Count == 1);
        }
        public void Test_Algebra_OneVariable_Linear_1()
        {
            //1+2=x
            var x = new Var('x');
            var lhs = new Term(Expression.Add, new List<object>() { 1, 2 });
            var equation = new Equation(lhs, x);
            bool result = equation.ContainsVar();
            Assert.True(result);
            Assert.True(equation.ToString().Equals("1+2=x"));

            equation.Eval();
            Assert.True(equation.CachedEntities.Count == 1);
            var outputEq = equation.CachedEntities.ToList()[0] as Equation;
            Assert.NotNull(outputEq);
            Assert.True(outputEq.ToString().Equals("x=3"));
            Assert.True(outputEq.Traces.Count == 1);
        }
        public void Test_Arith_3()
        {
            //1+2+3=6
            var lhs = new Term(Expression.Add, new List<object>() { 1, 2, 3 });
            var equation = new Equation(lhs, 6);
            bool result = equation.ContainsVar();
            Assert.False(result);
            Assert.True(equation.ToString().Equals("1+2+3=6"));

            object outputEq;
            bool? evalResult = equation.Eval(out outputEq);
            Assert.NotNull(evalResult);
            Assert.True(evalResult.Value);
            Assert.NotNull(outputEq);
            Assert.True(outputEq.ToString().Equals("6=6"));
            Assert.True(equation.Traces.Count == 1);
        }
        public void Test_Arith_2()
        {
            //1+2=4
            var lhs = new Term(Expression.Add, new List<object>() { 1, 2 });
            var equation = new Equation(lhs, 4);
            bool result = equation.ContainsVar();
            Assert.False(result);
            Assert.True(equation.ToString().Equals("1+2=4"));

            object obj = equation.Eval();
            Assert.NotNull(obj);
            var satisfied = obj as bool?;
            Assert.NotNull(satisfied);
            Assert.False(satisfied.Value);
            Assert.True(equation.CachedEntities.Count == 1);
            var cachedEq = equation.CachedEntities.ToList()[0] as Equation;
            Assert.NotNull(cachedEq);

            Assert.True(cachedEq.ToString().Equals("3=4"));
            Assert.True(cachedEq.Traces.Count == 1);
        }
Пример #5
0
        public void Test_Arith_3()
        {
            //1+2+3=6
            var lhs = new Term(Expression.Add, new List <object>()
            {
                1, 2, 3
            });
            var  equation = new Equation(lhs, 6);
            bool result   = equation.ContainsVar();

            Assert.False(result);
            Assert.True(equation.ToString().Equals("1+2+3=6"));

            object outputEq;
            bool?  evalResult = equation.Eval(out outputEq);

            Assert.NotNull(evalResult);
            Assert.True(evalResult.Value);
            Assert.NotNull(outputEq);
            Assert.True(outputEq.ToString().Equals("6=6"));
            Assert.True(equation.Traces.Count == 1);
        }
Пример #6
0
        public void Test_Algebra_OneVariable_Linear_1()
        {
            //1+2=x
            var x   = new Var('x');
            var lhs = new Term(Expression.Add, new List <object>()
            {
                1, 2
            });
            var  equation = new Equation(lhs, x);
            bool result   = equation.ContainsVar();

            Assert.True(result);
            Assert.True(equation.ToString().Equals("1+2=x"));

            equation.Eval();
            Assert.True(equation.CachedEntities.Count == 1);
            var outputEq = equation.CachedEntities.ToList()[0] as Equation;

            Assert.NotNull(outputEq);
            Assert.True(outputEq.ToString().Equals("x=3"));
            Assert.True(outputEq.Traces.Count == 1);
        }