public void CannotLookupAmbiguous()
        {
            var env = new StandardEnvironment();
            var one = new ConstantValueTestRow("one", "FOO");
            var two = new ConstantValueTestRow("two", "FOO");

            env.DefineFields(one, "one");
            env.DefineFields(two, "two");

            var ex = Assert.Catch <EvaluationException>(() => env.Lookup("FOO", null));

            Console.WriteLine(@"Expected exception: {0}", ex.Message);

            Assert.AreEqual("one", env.Lookup("FOO", "one"));
            Assert.AreEqual("two", env.Lookup("FOO", "two"));
        }
        public void CanLookupPrecedence()
        {
            // Lookup precedence for unqualified names:
            //   defined value < standard function < field value
            // Qualified names are always looked up on a row of fields
            // defined with the qualifier. CONCAT is a standard function.

            var          env       = new StandardEnvironment();
            var          row       = new ConstantValueTestRow("row", "CONCAT", "FOO");
            const string qualifier = "qualifier";

            Assert.Catch <EvaluationException>(() => env.Lookup("FOO", null));
            Assert.IsInstanceOf <Function>(env.Lookup("CONCAT", null));
            Assert.Catch <EvaluationException>(() => env.Lookup("CONCAT", qualifier));

            env.DefineFields(row, qualifier);

            Assert.AreEqual("row", env.Lookup("FOO", null));
            Assert.IsInstanceOf <Function>(env.Lookup("CONCAT", null));
            Assert.AreEqual("row", env.Lookup("CONCAT", qualifier));

            env.DefineValue("FOO", "foo");
            env.DefineValue("CONCAT", "value");

            Assert.AreEqual("foo", env.Lookup("FOO", null));
            Assert.AreEqual("value", env.Lookup("CONCAT", null));
            Assert.AreEqual("row", env.Lookup("CONCAT", qualifier));

            env.ForgetValue("CONCAT");
            env.ForgetValue("FOO");

            Assert.AreEqual("row", env.Lookup("FOO", null));
            Assert.IsInstanceOf <Function>(env.Lookup("CONCAT", null));
            Assert.AreEqual("row", env.Lookup("CONCAT", qualifier));

            env.ForgetFields("qualifier");

            Assert.Catch <EvaluationException>(() => env.Lookup("FOO", null));
            Assert.IsInstanceOf <Function>(env.Lookup("CONCAT", null));
            Assert.Catch <EvaluationException>(() => env.Lookup("CONCAT", qualifier));
        }