public void MultipleWhereParameters() { var c = new QueryCommand <Category>(); c.Where(category => category.Id == "abc").Where(category => category.Key == "def"); QueryRequestMessageBuilder queryRequestMessageBuilder = new QueryRequestMessageBuilder( this.clientFixture.GetService <IEndpointRetriever>(), this.clientFixture.GetService <IParametersBuilderFactory <IAdditionalParametersBuilder> >(), this.clientFixture.GetService <IParametersBuilderFactory <IQueryParametersBuilder> >()); HttpRequestMessage httpRequestMessage = queryRequestMessageBuilder.GetRequestMessage(c); Assert.Equal("categories?where=id%20%3D%20%22abc%22&where=key%20%3D%20%22def%22&withTotal=false", httpRequestMessage.RequestUri.ToString()); }
public void GetQueryRequestMessageWithSort() { QueryCommand <Message> queryCommand = new QueryCommand <Message>(); queryCommand.Sort(message => message.Id).Sort(message => message.CreatedAt, SortDirection.Descending); QueryRequestMessageBuilder queryRequestMessageBuilder = new QueryRequestMessageBuilder( this.clientFixture.GetService <IEndpointRetriever>(), this.clientFixture.GetService <IParametersBuilderFactory <IAdditionalParametersBuilder> >(), this.clientFixture.GetService <IParametersBuilderFactory <IQueryParametersBuilder> >() ); HttpRequestMessage httpRequestMessage = queryRequestMessageBuilder.GetRequestMessage(queryCommand); Assert.Equal("messages?sort=id%20asc&sort=createdAt%20desc&withTotal=false", httpRequestMessage.RequestUri.ToString()); }
public void GetQueryRequestMessageWithExpand() { List <Expansion <Category> > expansions = new List <Expansion <Category> >(); ReferenceExpansion <Category> parentExpansion = new ReferenceExpansion <Category>(c => c.Parent); expansions.Add(parentExpansion); QueryCommand <Category> queryCommand = new QueryCommand <Category>(); queryCommand.SetExpand(expansions); QueryRequestMessageBuilder queryRequestMessageBuilder = new QueryRequestMessageBuilder( this.clientFixture.GetService <IClientConfiguration>(), this.clientFixture.GetService <IEndpointRetriever>(), this.clientFixture.GetService <IParametersBuilderFactory <IAdditionalParametersBuilder> >()); HttpRequestMessage httpRequestMessage = queryRequestMessageBuilder.GetRequestMessage(queryCommand); Assert.Equal(this.clientFixture.APIBaseAddressWithProjectKey + "/categories?expand=parent", httpRequestMessage.RequestUri.ToString()); }
public void GetQueryRequestMessageWithTwoExpands() { List <Expansion <Category> > expansions = new List <Expansion <Category> >(); ReferenceExpansion <Category> parentExpansion = new ReferenceExpansion <Category>(c => c.Parent); ReferenceExpansion <Category> firstAncestorExpansion = new ReferenceExpansion <Category>(c => c.Ancestors[0]); expansions.Add(parentExpansion); expansions.Add(firstAncestorExpansion); QueryCommand <Category> queryCommand = new QueryCommand <Category>(); queryCommand.SetExpand(expansions); QueryRequestMessageBuilder queryRequestMessageBuilder = new QueryRequestMessageBuilder( this.clientFixture.GetService <IEndpointRetriever>(), this.clientFixture.GetService <IParametersBuilderFactory <IAdditionalParametersBuilder> >(), this.clientFixture.GetService <IParametersBuilderFactory <IQueryParametersBuilder> >()); HttpRequestMessage httpRequestMessage = queryRequestMessageBuilder.GetRequestMessage(queryCommand); Assert.Equal("categories?expand=parent&expand=ancestors%5B0%5D&withTotal=false", httpRequestMessage.RequestUri.ToString()); }