public void Sort_SearchSort_To_Output_Json()
        {
            var searchSort = new IdSearchSort();

            var searchParams = new SearchOptions();

            searchParams.Sort(searchSort);

            var result = searchParams.ToJson().ToString(Formatting.None);

            var expected = JsonConvert.SerializeObject(new
            {
                ctl = new
                {
                    timeout = 75000
                },
                sort = new[]
                {
                    new
                    {
                        by = "id"
                    }
                }
            }, Formatting.None);

            Assert.Equal(expected, result);
        }
Exemplo n.º 2
0
        public void Sort_SearchSort_To_Output_Json()
        {
            var searchSort = new IdSearchSort();

            var searchOptions = new SearchOptions();

            searchOptions.Sort(searchSort);

            var result = searchOptions.ToJson().ToString(Formatting.None);

            var expected = JsonConvert.SerializeObject(new
            {
                ctl = new
                {
                    consistency = new
                    {
                        level = "not_bounded"
                    }
                },
                sort = new[]
                {
                    new
                    {
                        by = "id"
                    }
                }
            }, Formatting.None);

            Assert.Equal(expected, result);
        }
Exemplo n.º 3
0
        public void Omits_Decending_If_False()
        {
            var sort   = new IdSearchSort();
            var result = sort.Export().ToString(Formatting.None);

            var expected = JsonConvert.SerializeObject(new
            {
                by = "id"
            }, Formatting.None);

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 4
0
        public void Outputs_Valid_Json()
        {
            var sort   = new IdSearchSort(true);
            var result = sort.Export().ToString(Formatting.None);

            var expected = JsonConvert.SerializeObject(new
            {
                by        = "id",
                decending = true
            }, Formatting.None);

            Assert.AreEqual(expected, result);
        }