public void GivenQueryConstraint_When_OnlySortByMethodInvoked_Then_SortOrderShouldBeAscending()
        {
            var queryConstraints = new QueryConstraints();

            queryConstraints.Page(1).SortBy("name");
            Assert.AreEqual(queryConstraints.SortOrder, SortOrder.Ascending);
        }
Exemple #2
0
        public IQueryConstraints GetQueryConstraints()
        {
            var constraints = new QueryConstraints();

            if (GlasswareId.HasValue)
            {
                constraints.AddFilter("glasswareId", GlasswareId.Value);
            }
            if (StyleId.HasValue)
            {
                constraints.AddFilter("styleId", StyleId.Value);
            }
            if (AvailabilityId.HasValue)
            {
                constraints.AddFilter("availableId", AvailabilityId.Value);
            }
            if (!String.IsNullOrEmpty(Sort))
            {
                constraints.SortBy(Sort);
            }
            if (!String.IsNullOrEmpty(Order))
            {
                if (Order.ToLower().Equals("desc"))
                {
                    constraints.Descending();
                }
            }
            if (Page.HasValue)
            {
                constraints.Page(Page.Value);
            }
            return(constraints);
        }
        public void GivenQueryConstraint_When_SortPropertyNameMethodInvoked_Then_SortPropertyNameAreSetCorrectly()
        {
            var queryConstraints = new QueryConstraints();

            queryConstraints.Page(1).SortBy("name");
            Assert.AreEqual(queryConstraints.SortPropertyName, "name");
        }
        public void GivenQueryConstraint_When_SortByAndSortByDescMethodsUsedTogahter_Then_SortORderShouldBeDescinding()
        {
            var queryConstraints = new QueryConstraints();

            queryConstraints.Page(1).SortBy("name").Descending();
            Assert.AreEqual(queryConstraints.SortPropertyName, "name");
            Assert.AreEqual(queryConstraints.SortOrder, SortOrder.Descending);
        }
        public void TenthPage()
        {
            var constraints = new QueryConstraints <User>();

            constraints.Page(10, 20);

            Assert.Equal(10, constraints.PageNumber);
            Assert.Equal(20, constraints.PageSize);
            Assert.Equal((10 - 1) * 20, constraints.StartRecord);
        }
        public void FirstPage()
        {
            var constraints = new QueryConstraints <User>();

            constraints.Page(1, 50);

            Assert.Equal(1, constraints.PageNumber);
            Assert.Equal(50, constraints.PageSize);
            Assert.Equal(0, constraints.StartRecord);
        }
        public void TenthPage()
        {
            var constraints = new QueryConstraints<User>();

            constraints.Page(10, 20);

            Assert.Equal(10, constraints.PageNumber);
            Assert.Equal(20, constraints.PageSize);
            Assert.Equal((10 - 1)*20, constraints.StartRecord);
        }
        public void FirstPage()
        {
            var constraints = new QueryConstraints<User>();

            constraints.Page(1, 50);

            Assert.Equal(1, constraints.PageNumber);
            Assert.Equal(50, constraints.PageSize);
            Assert.Equal(0, constraints.StartRecord);
        }
Exemple #9
0
        public void GivenRestRequestExtensions_When_ConstraintsAppliedToRestRequest_ParameterListShouldBeCunstractedAsExpected()
        {
            var request     = new RestRequest();
            var constraints = new QueryConstraints();

            constraints.Page(2).SortBy("name").Descending();
            constraints.AddFilter("glasswareId", 1);
            request.ApplyConstraints(constraints);

            Assert.AreEqual(2, (int)request.Parameters.Single(p => p.Name == "p").Value);
            Assert.AreEqual(constraints.GetSortParameterString(), request.Parameters.Single(p => p.Name == "sort").Value);
            Assert.AreEqual(constraints.SortPropertyName, request.Parameters.Single(p => p.Name == "order").Value);
            Assert.AreEqual(1, (int)request.Parameters.Single(p => p.Name == "glasswareId").Value);
        }