Ejemplo n.º 1
0
        public void GivenFilterParameters_When_QueryConstraintsMethodInvoked_ShouldReturnQueryConstaintsWithCorrectState()
        {
            var filterParameters = new FilterParameters
            {
                AvailabilityId = 1
            };
            QueryConstraints constraints = filterParameters.GetQueryConstraints() as QueryConstraints;

            Assert.AreEqual(constraints.GetSortParameterString(), "ASC");
            Assert.AreEqual(constraints.SortPropertyName, "name");
            Assert.AreEqual(1, (int)constraints.FilterParameters.Single(p => p.Key == "availableId").Value);
        }
Ejemplo n.º 2
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);
        }