Exemplo n.º 1
0
        public void UndefConstTest()
        {
            var parameters = new ParameterCollection();

            var undef = new Undefine(new Variable("π"));

            Assert.Throws <ArgumentException>(() => undef.Execute(parameters));
        }
Exemplo n.º 2
0
        public void UndefVarTest()
        {
            var parameters = new ParameterCollection {
                { "a", 1 }
            };

            var undef = new Undefine(new Variable("a"));

            undef.Execute(parameters);
            Assert.False(parameters.ContainsKey("a"));
        }
Exemplo n.º 3
0
        public void UndefFuncTest()
        {
            var key1 = new UserFunction("f", new IExpression[0]);
            var key2 = new UserFunction("f", new IExpression[1]);

            var functions = new FunctionCollection {
                { key1, new Number(1) }, { key2, new Number(2) }
            };

            var undef  = new Undefine(key1);
            var result = undef.Execute(functions);

            Assert.False(functions.ContainsKey(key1));
            Assert.True(functions.ContainsKey(key2));
            Assert.Equal("The 'f()' function is removed.", result);
        }