public void TestValidRequestWithId()
    {
      IPagingParameters paging = new MutablePagingParameters(3, 5);
      var request = new ReadItemsByIdParameters(this.sessionConfig, this.defaultSource, null, paging, "{item-id}");

      string result = this.builderForId.GetUrlForRequest(request);
      string expected = "http://tumba.yumba/-/item/v1?sc_itemid=%7bitem-id%7d&page=3&pageSize=5";

      Assert.AreEqual(expected, result);
    }
    public void TestValidRequestWithIdForShellSite()
    {
      IPagingParameters paging = new MutablePagingParameters(1, 10);
      var request = new ReadItemsByIdParameters(this.sitecoreShellConfig, this.defaultSource, null, paging, "{item-id}");

      string result = this.builderForId.GetUrlForRequest(request);
      string expected = "http://trololo.net/-/item/v234%2fsitecore%2fshell?sc_itemid=%7bitem-id%7d&page=1&pageSize=10";

      Assert.AreEqual(expected, result);
    }
    public void TestNegativeItemsCountIsNotAllowed()
    {
      IPagingParameters paging = new MutablePagingParameters(4, -1);
      var request = new ReadItemByQueryParameters(this.sessionConfig, this.defaultSource, null, paging, "/sitecore/content/*");

      Assert.Throws<ArgumentException>(() => this.builderForQuery.GetUrlForRequest(request));
    }
    public void TestNegativePageNumberIsNotAllowed()
    {
      IPagingParameters paging = new MutablePagingParameters(-1, 5);
      var request = new ReadItemByPathParameters(this.sessionConfig, this.defaultSource, null, paging, "/sitecore/content");

      Assert.Throws<ArgumentException>(() => this.builderForPath.GetUrlForRequest(request));
    }
    public void TestValidRequestWithQueryForShellSite()
    {
      IPagingParameters paging = new MutablePagingParameters(1, 10);
      var request = new ReadItemByQueryParameters(this.sitecoreShellConfig, this.defaultSource, null, paging, "/x/y/z");

      string result = this.builderForQuery.GetUrlForRequest(request);
      string expected = "http://trololo.net/-/item/v234%2fsitecore%2fshell?query=%2fx%2fy%2fz&page=1&pageSize=10";

      Assert.AreEqual(expected, result);
    }
    public void TestValidRequestWithQuery()
    {
      IPagingParameters paging = new MutablePagingParameters(3, 5);
      var request = new ReadItemByQueryParameters(this.sessionConfig, this.defaultSource, null, paging, "/sitecore/content");

      string result = this.builderForQuery.GetUrlForRequest(request);
      string expected = "http://tumba.yumba/-/item/v1?query=%2fsitecore%2fcontent&page=3&pageSize=5";

      Assert.AreEqual(expected, result);
    }
    public void TestReadItemQueryRequestCopiesPagingOptions()
    {
      var defaultSource = new MutableItemSource("master", "en", 33);
      var sessionSettings = new MutableSessionConfig("localhost", "/sitecore/shell", "v100500");

      ScopeParameters scope = new ScopeParameters();
      scope.AddScope(ScopeType.Parent);
      scope.AddScope(ScopeType.Self);

      string[] fields = { "Ukraine", "is", "Europe" };
      var queryParameters = new QueryParameters(PayloadType.Content, scope, fields);

      var pagingSettings = new MutablePagingParameters(1, 10);
      ReadItemByQueryParameters request = new ReadItemByQueryParameters(
        sessionSettings,
        defaultSource,
        queryParameters,
        pagingSettings,
        "/x/y/z");
      var otherRequest = request.DeepCopyGetItemByQueryRequest();


      {
        pagingSettings.PageNumber = 20;
        pagingSettings.ItemsPerPageCount = 100500;


        Assert.AreEqual(10, otherRequest.PagingSettings.ItemsPerPageCount);
        Assert.AreEqual(1, otherRequest.PagingSettings.PageNumber);
      }
    }