public void BuildingComplexMapReduceJobsWithTheApiProducesTheCorrectCommand()
        {
            var query = new RiakMapReduceQuery
                {
                    ContentType = MrContentType
                }
                .Inputs("animals")
                .MapJs(m => m.Source("function(o) { if (o.key.indexOf('spider') != -1) return [1]; return []; }"))
                .ReduceJs(r => r.Name("Riak.reduceSum").Keep(true));

            var request = query.ToMessage();
            request.request.ShouldEqual(ComplexMrJobText.ToRiakString());
        }
        public void BuildingComplexMapReduceJobsWithFiltersProducesTheCorrectCommand()
        {
            var query = new RiakMapReduceQuery
                {
                    ContentType = MrContentType
                }
                .Inputs("animals")
                //.Filter(new Matches<string>("spider"))
                .Filter(f => f.Matches("spider"))
                .MapJs(m => m.Source("function(o) { return [1]; }"))
                .ReduceJs(r => r.Name("Riak.reduceSum").Keep(true));

            var request = query.ToMessage();
            request.request.ShouldEqual(ComplexMrJobWithFilterText.ToRiakString());
        }
        public void BuildingMapReducePhaseWithObjectArgumentProducesCorrectResult()
        {
            var query = new RiakMapReduceQuery { ContentType = MrContentType }
                .Inputs("animals")
                .ReduceJs(c => c.Name("Riak.reduceSlice").Keep(true).Argument(new { reduce_phase_only_1 = true }));

            var request = query.ToMessage();
            request.request.ShouldEqual(MrJobWithObjectArgument.ToRiakString());
        }
        public void QueryingDollarKeyDoesNotAppendBinIndexSuffix()
        {
            var query = new RiakMapReduceQuery
                {
                    ContentType = MrContentType
                }
                .Inputs(RiakIndex.Range("animals", "$key", "0", "zzzzz"));

            var request = query.ToMessage();
            var requestString = request.request.FromRiakString();

            requestString.Contains("$key").ShouldBeTrue();
            requestString.Contains("$key_bin").ShouldBeFalse();
        }
        public void BuildingSimpleMapReduceJobsWithTimeoutProducesTheCorrectCommand()
        {
            var query = new RiakMapReduceQuery
            {
                ContentType = MrContentType,
                Timeout = 100200
            }
                .Inputs("animals")
                .MapJs(m => m.Source("function(v) { return [v]; }").Keep(true));

            var request = query.ToMessage();
            request.content_type.ShouldEqual(MrContentType.ToRiakString());
            request.request.ShouldEqual(MrJobWithTimeoutText.ToRiakString());
        }
        public void BuildingSimpleMapReduceJobsWithTheApiProducesByteArrays()
        {
            var query = new RiakMapReduceQuery
                {
                    ContentType = MrContentType
                }
                .Inputs("animals")
                .MapJs(m => m.Source("function(v) { return [v]; }").Keep(true));

            var request = query.ToMessage();
            request.content_type.ShouldEqual(MrContentType.ToRiakString());
            request.request.ShouldEqual(MrJobText.ToRiakString());
        }
        public void BuildingMapReducePhaseWithVaueTypeArgumentProducesCorrectResult()
        {
            var query = new RiakMapReduceQuery { ContentType = MrContentType }
                .Inputs("animals")
                .ReduceJs(c => c.Name("Riak.reduceSlice").Keep(true).Argument("slartibartfast"));

            var request = query.ToMessage();
            request.request.ShouldEqual(MrJobWithValueTypeArgument.ToRiakString());
        }