public void TestJsMapFunction()
        {
            var c = new JSViewCompiler();
            var mapBlock = c.CompileMap("function(doc){emit(doc.key, doc);}", "javascript");
            Assert.IsNotNull(mapBlock);

            var doc = new Dictionary<string, object> {
                { "_id", "doc1" },
                { "_rev", @"1-xyzzy" },
                { "key", "value" }
            };

            var emitted = new List<object>();
            EmitDelegate emit = (key, value) =>
            {
                Console.WriteLine("Emitted: {0} -> {1}", key, value);
                emitted.Add(key);
                emitted.Add(value);
            };
            mapBlock(doc, emit);

            CollectionAssert.AreEqual(new List<object> { "value", doc }, emitted);
        }
        public void TestJsLogFunction()
        {
            // This case will test that calling log() function doesn't cause any errors running the JS map
            // map function.
            var c = new JSViewCompiler();
            var mapBlock = c.CompileMap("function(doc){log('Log Message'); emit(doc.key, doc);}", "javascript");
            Assert.IsNotNull(mapBlock);

            var doc = new Dictionary<string, object> {
                { "_id", "doc1" },
                { "_rev", @"1-xyzzy" },
                { "key", "value" }
            };

            var emitted = new List<object>();
            EmitDelegate emit = (key, value) => emitted.Add(value);
            mapBlock(doc, emit);

            CollectionAssert.AreEqual(new List<object> { doc }, emitted);
        }