Exemplo n.º 1
0
        public void ThenItShouldHaveAConsistentOrder()
        {
            var query = new CosmosQuery(CosmosCombinationOperator.And)
                        .AddCondition("Name", DataOperator.Equals, "some-thing");

            var queryOrderBy = query.ToString().Substring(query.ToString().Length - CosmosQueryTestConstants.OrderBy.Length);

            Assert.AreEqual(CosmosQueryTestConstants.OrderBy, queryOrderBy);
        }
Exemplo n.º 2
0
        public void ThenItShouldAddOffsetAndLimitToQuery()
        {
            var query = new CosmosQuery(CosmosCombinationOperator.And)
                        .AddCondition("Name", DataOperator.Equals, "some-thing")
                        .TakeResultsBetween(10, 50);

            var expectedOffsetLimit = $"OFFSET 10 LIMIT 50";

            Assert.AreEqual(expectedOffsetLimit, query.ToString().Substring(query.ToString().Length - expectedOffsetLimit.Length));
        }
Exemplo n.º 3
0
        public void ThenItShouldPrefixCountQueryWithSelectCount()
        {
            var query = new CosmosQuery(CosmosCombinationOperator.And)
                        .AddCondition("Name", DataOperator.Equals, "some-thing");

            Assert.AreEqual(CosmosQueryTestConstants.CountQueryPrefix, query.ToString(true).Substring(0, CosmosQueryTestConstants.CountQueryPrefix.Length));
        }
Exemplo n.º 4
0
        public void ThenItShouldNotOrderByForCountQuery()
        {
            var query = new CosmosQuery(CosmosCombinationOperator.And)
                        .AddCondition("Name", DataOperator.Equals, "some-thing");

            var orderByIndex = query.ToString(true).IndexOf(CosmosQueryTestConstants.OrderBy, StringComparison.InvariantCultureIgnoreCase);

            Assert.AreEqual(-1, orderByIndex);
        }
Exemplo n.º 5
0
        public void ThenItShouldNotOffsetLimitForCountQuery()
        {
            var query = new CosmosQuery(CosmosCombinationOperator.And)
                        .AddCondition("Name", DataOperator.Equals, "some-thing")
                        .TakeResultsBetween(10, 50);

            var offsetLimitIndex = query.ToString(true).IndexOf("OFFSET 10 LIMIT 50", StringComparison.InvariantCultureIgnoreCase);

            Assert.AreEqual(-1, offsetLimitIndex);
        }
Exemplo n.º 6
0
        internal static string QueryWithoutOrderByOrSkip(CosmosQuery query)
        {
            var queryText = query.ToString();

            var orderByIndex = queryText.IndexOf(OrderBy, StringComparison.InvariantCultureIgnoreCase);

            if (orderByIndex > -1)
            {
                queryText = queryText.Substring(0, orderByIndex).Trim();
            }

            return(queryText);
        }